A JavaScript library for building user interfaces.
class Welcome extends React.Component { render() { return <h1>Hello {this.props.name}</h1>; } } const element = <Welcome name="Sara" />;
class Button extends React.Component { constructor() { super(); this.state = { count: 0, }; } updateCount() { this.setState((prevState, props) => { return { count: prevState.count + 1 } }); } render() { return (<button onClick={() => this.updateCount()} > Clicked {this.state.count} times </button>); } }
constructor() { super(); this.state = { count: 0, }; }
updateCount() { this.setState((prevState, props) => { return { count: prevState.count + 1 } }); }
React.createElement
class Greeting extends React.Component { constructor(props) { super(props); // Define your state object here this.state = { name: ‘Jane Doe’ } } render(){ return <h1>Hello { this.state.name }</h1>; } }
Data Flow - React
Follow me @tkssharma
By Tarun Sharma
React js props State and Event Handling