Skip to content

Instantly share code, notes, and snippets.

@samcorcos
Created August 11, 2016 03:07
Show Gist options
  • Save samcorcos/4c9941d398c14ba8f93a7d071d36fdb0 to your computer and use it in GitHub Desktop.
Save samcorcos/4c9941d398c14ba8f93a7d071d36fdb0 to your computer and use it in GitHub Desktop.
import React from 'react'
let counter = 0
class App extends React.Component {
constructor(props) {
super(props)
this.addOne = this.addOne.bind(this)
}
addOne() {
counter += 1
this.forceUpdate()
}
render() {
return (
<div>
<button
onClick={ this.addOne }>
Increment
</button>
{ counter }
</div>
)
}
}
export default App
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment