Skip to content

Instantly share code, notes, and snippets.

@Ami777
Created March 2, 2017 15:21
Show Gist options
  • Save Ami777/ab32dae9655ade09383cc635cca4acd7 to your computer and use it in GitHub Desktop.
Save Ami777/ab32dae9655ade09383cc635cca4acd7 to your computer and use it in GitHub Desktop.
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