Created
March 2, 2017 11:42
-
-
Save Ami777/1c673eb171327b710502cdc85f41204e 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 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