Skip to content

Pass entire file into fileTemplate#2

Open
nick-michael wants to merge 1 commit intowoodpig07:masterfrom
nick-michael:patch-1
Open

Pass entire file into fileTemplate#2
nick-michael wants to merge 1 commit intowoodpig07:masterfrom
nick-michael:patch-1

Conversation

@nick-michael
Copy link
Copy Markdown

Lets you use file data in other functions in the template:
e.g

  customFile = (props) => {
    return (
      <a  className="file-tree-item" draggable="true"  onDragStart={(e) => this.handleDragStart(e, props)}><span className='file-tree-svg'
        dangerouslySetInnerHTML={{__html: '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="24" height="24" viewBox="0 0 24.00 24.00" enable-background="new 0 0 24.00 24.00" xml:space="preserve">' +
        '<path d="M13,9H18.5L13,3.5V9M6,2H14L20,8V20A2,2 0 0,1 18,22H6C4.89,22 4,21.1 4,20V4C4,2.89 4.89,2 6,2M15,18V16H6V18H15M18,14V12H6V14H18Z"></path>' +
        '</svg>'}} />
        { props.name }
      </a>
    )
  }

So now we pass props (which in this case is now the entire file) into the onDragStart handler

Lets you use file data in other functions in the template:
e.g
```
  customFile = (props) => {
    return (
      <a  className="file-tree-item" draggable="true"  onDragStart={(e) => this.handleDragStart(e, props)}><span className='file-tree-svg'
        dangerouslySetInnerHTML={{__html: '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="24" height="24" viewBox="0 0 24.00 24.00" enable-background="new 0 0 24.00 24.00" xml:space="preserve">' +
        '<path d="M13,9H18.5L13,3.5V9M6,2H14L20,8V20A2,2 0 0,1 18,22H6C4.89,22 4,21.1 4,20V4C4,2.89 4.89,2 6,2M15,18V16H6V18H15M18,14V12H6V14H18Z"></path>' +
        '</svg>'}} />
        { props.name }
      </a>
    )
  }
```

So now we pass props (which in this case is now the entire file) into the `onDragStart` handler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant