Skip to content

Latest commit

 

History

History
40 lines (31 loc) · 854 Bytes

README.md

File metadata and controls

40 lines (31 loc) · 854 Bytes

Simple example of click counter

you can check it out here


class App extends React.Component {
    constructor(props) {
        super(props);
        this.state = {value: 0};
        this.buttonClicked = this.buttonClicked.bind(this);
    }

    buttonClicked() {
        this.setState({value: this.state.value + 1});
    }

    render() {
        return (
            <div>
                <div className="displayedNumber">{this.state.value}</div>
                <button type="button" class="btn btn-primary btn-lg" onClick={this.buttonClicked}>Count me!</button>
            </div>
        );
    }
}

ReactDOM.render(
    <App/>,
    document.getElementById('root')
);

export default App;

To run on http://localhost:3000:

  • $ yarn start