Sha256: 1212abc4561ac354b41699dd2dee6d7cef7ce60dd1114d5331767468897d3625
Contents?: true
Size: 704 Bytes
Versions: 6
Compression:
Stored size: 704 Bytes
Contents
import React, {Component} from 'react'; export default class Counter extends Component { constructor(props) { super(props); this.state = { value: this.props.startingValue || 0 }; } handleMinusClick() { const value = this.state.value; this.setState({value: value - 1}); } handlePlusClick() { const value = this.state.value; this.setState({value: value + 1}); } render() { return ( <div className="counter"> <span style={{marginRight: '1rem'}}>{this.state.value}</span> <button onClick={this.handleMinusClick.bind(this)}>-</button> <button onClick={this.handlePlusClick.bind(this)}>+</button> </div> ); } }
Version data entries
6 entries across 6 versions & 1 rubygems