Last active
May 4, 2018 15:01
-
-
Save jake-daniels/6f1cc1789463a2281bdc52647e58fb49 to your computer and use it in GitHub Desktop.
Table component with nested components.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Table extends React.Component { | |
Head = () => { | |
return ( | |
<div className='head'> | |
</div> | |
) | |
} | |
Body = () => { | |
return ( | |
<div className='body'> | |
{this.props.items.map((item, index) => | |
<this.Row key={index} data={item}/> | |
)} | |
</div> | |
) | |
} | |
Row = ({data}) => { | |
return ( | |
<div className='row'> | |
<div className='column'> | |
{data.someProperty} | |
</div> | |
{/* ...more columns */} | |
</div> | |
) | |
} | |
render () { | |
return ( | |
<div className='table'> | |
<this.Head /> | |
<this.Body /> | |
</div> | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment