Last active
August 29, 2015 14:19
-
-
Save benkeen/c68c0635d3be672482ef to your computer and use it in GitHub Desktop.
Overriding React 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
var Table = React.createClass({ | |
getRows: function () { | |
return _.map(this.props.rows, function (row, i) { | |
return <TableRow key={i} row={row} /> | |
}); | |
}, | |
render: function () { | |
return ( | |
<table> | |
<thead> | |
<TableHeader /> | |
</thead> | |
<tbody> | |
{this.getRows()} | |
</tbody> | |
</table> | |
); | |
} | |
}); | |
var TableHeader = React.createClass({ | |
render: function () { | |
return ( | |
<tr> | |
<th>Col 1</th> | |
<th>Col 2</th> | |
</tr> | |
); | |
} | |
}); | |
var TableRow = function () { | |
render: function () { | |
return ( | |
<tr> | |
<td>{this.props.row.col1}</td> | |
<td> | |
{this.props.row.col1} | |
<Tooltip text={this.props.row.desc} /> | |
</td> | |
</tr> | |
); | |
} | |
}; | |
var Tooltip = React.createClass({ | |
render: function () { | |
return ( | |
<div className="tt">{this.props.text}</div> | |
); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment