Upload
bonnie-dipasquale
View
253
Download
3
Embed Size (px)
Citation preview
Components are more than HTML templates
What it isn’t
● No explicit data binding● You never need to tell your
component to re-render
What it is
● Markup● Behavior● State
Each component is a mini self-contained API
[ code ] codepen
/** Comment Component: renders <li /> */
var Comment = React.createClass({ propTypes: { className: React.PropTypes.string, id: React.PropTypes.string, commentText: React.PropTypes.string }, render: function() { return ( <li
id={this.props.id} className={this.props.className}>
{this.props.commentText} </li>
); }});
● Decoupled from application data - same component can be used in a data entry app, QA app, etc.
● Event handlers are attached after the first rendering pass, allowing for server-side rendering of the HTML or re-use on mobile devices
● Behavior is also passed down through props, making it easier to have the component behave differently based on context
React tools for the browserDisplays component name, state & propsOutput the selected component to the console with $rNew team members can quickly find their way around the codebase