Skip to content

Instantly share code, notes, and snippets.

@Anirudhk94
Created January 11, 2019 20:23
Show Gist options
  • Save Anirudhk94/6dfa665d9b48084ac886adda9e7e120c to your computer and use it in GitHub Desktop.
Save Anirudhk94/6dfa665d9b48084ac886adda9e7e120c to your computer and use it in GitHub Desktop.
class Button extends React.Component {
render() {
return(
<button onClick={this.props.onClickFunction}>
Plus One
</button>
)
}
}
class Text extends React.Component {
render() {
return(
<div>
{this.props.display}
</div>
)
}
}
class App extends React.Component {
state = {counter : 0};
incrementCounter = () => {
this.setState((prevState) => {
return {
counter: prevState.counter + 1
}
})
}
render() {
return(
<div>
<Button onClickFunction = {this.incrementCounter}/>
<Text display = {this.state.counter}/>
</div>
)
}
}
ReactDOM.render(<App />, mountNode)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment