Skip to content

Instantly share code, notes, and snippets.

@Ami777
Created March 2, 2017 11:42
Show Gist options
  • Save Ami777/1c673eb171327b710502cdc85f41204e to your computer and use it in GitHub Desktop.
Save Ami777/1c673eb171327b710502cdc85f41204e to your computer and use it in GitHub Desktop.
import React from 'react';
import ReactDOM from 'react-dom';
document.addEventListener('DOMContentLoaded', function(){
class Nonsense extends React.Component {
constructor(props){
super(props);
this.state = {
buttonsText : 'Klik!',
thirdBtnWidth: 'auto',
};
}
handleFirstBtnClick = () => {
console.log( 'Pierwszy przycisk kliknięty' );
};
handleSecondBtnClick = () => {
this.setState({
buttonsText : 'Click!',
});
};
handleThirdBtnClick = () => {
this.setState({
thirdBtnWidth : '300px',
});
};
render(){
return <div>
<button onClick={this.handleFirstBtnClick}>
{this.state.buttonsText}
</button>
<button onClick={this.handleSecondBtnClick}>
{this.state.buttonsText}
</button>
<button onClick={this.handleThirdBtnClick} style={{width:this.state.thirdBtnWidth}}>
{this.state.buttonsText}
</button>
</div>;
}
}
class App extends React.Component {
render(){
return <Nonsense />;
}
}
ReactDOM.render(
<App />,
document.getElementById('app')
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment