Created
March 2, 2017 15:21
-
-
Save Ami777/ab32dae9655ade09383cc635cca4acd7 to your computer and use it in GitHub Desktop.
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 from 'react'; | |
import ReactDOM from 'react-dom'; | |
document.addEventListener('DOMContentLoaded', function(){ | |
class MyCheckbox extends React.Component { | |
constructor(props){ | |
super(props); | |
this.state = { | |
isOn : false, | |
}; | |
} | |
handleChangeClick = () => { | |
this.setState({ | |
isOn : ! this.state.isOn | |
}); | |
} | |
render(){ | |
return <div> | |
<button onClick={this.handleChangeClick}> | |
{ this.state.isOn ? 'TAK' : 'NIE' } | |
</button> | |
</div>; | |
} | |
} | |
class App extends React.Component { | |
render(){ | |
return <MyCheckbox />; | |
} | |
} | |
ReactDOM.render( | |
<App />, | |
document.getElementById('app') | |
); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment