Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Counter(props) {
- return <div>
- <p>{{ props.number }}</p>
- <button onclick=props.onclick >Click Me</buton>
- </div>
- }
- class CounterState extends React.Component {
- constructor(props) {
- super(props)
- this.state = { count: 0 };
- }
- render() {
- <Counter number={this.state.count} onclick={this.handleClick} />
- }
- handleClick() {
- this.setState({ count: this.state.count + 1});
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement