Created
June 22, 2018 03:21
-
-
Save ManasJayanth/954de3ca2d695961bbf5aee5abd7a7a5 to your computer and use it in GitHub Desktop.
Snippets for Learn you some custom react renderers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
class App extends Component { | |
constructor() { | |
super(); | |
this.state = { | |
count: 0 | |
}; | |
} | |
render() { | |
const onClickHandler = () => { | |
this.setState(state => { | |
return { | |
count: state.count + 1 | |
}; | |
}); | |
}; | |
return ( | |
<div> | |
<div>{this.state.count}</div> | |
<button onClick={onClickHandler}>Increment</button> | |
</div> | |
); | |
} | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment