<h2>It is {new Date().toLocaleTimeString()}.</h2> </div> ); ReactDOM.render(element, document.getElementById('root')); } setInterval(tick, 1000); Rendering an element multiple times into the DOM
null, "Hello ", this.props.name ); } } ReactDOM.render(React.createElement(HelloMessage, { name: "Taylor" }), document.getElementById('hello-example')); This is the real code executed by the browser
null, "Hello ", this.props.name ); } } ReactDOM.render(React.createElement(HelloMessage, { name: "Taylor" }), document.getElementById('hello-example')); Look like the component is a “function”
<h2>It is {new Date().toLocaleTimeString()}.</h2> </div> ); ReactDOM.render( element, document.getElementById('root') ); } setInterval(tick, 1000); Let’s make this in a truly reusable component
{props.date.toLocaleTimeString()}.</h2> </div> ); } function tick() { ReactDOM.render( <Clock date={new Date()} />, document.getElementById('root') ); } setInterval(tick, 1000); Clock is now an isolated component but doesn’t manage the time to be displayed
{date: new Date()}; } render() { return ( <div> <h1>Hello, world!</h1> <h2>It is {this.state.date.toLocaleTimeString()}.</h2> </div> ); } } State use instead of props