model reactjs code example
Example 1: props and state react
function tick() {
const element = (
Hello, world!
It is {new Date().toLocaleTimeString()}.
);
ReactDOM.render( element, document.getElementById('root') );}
setInterval(tick, 1000);
Example 2: diagram how props are passed in react
import React, { Component } from 'react'; class App extends Component { render() { const greeting = 'Welcome to React'; return (
); }} class Greeting extends Component { render() { return {this.props.greeting}
; }} export default App;