Created
May 6, 2020 09:09
-
-
Save Ratstail91/0746c0da5215a490b2fcc1c44407ae0a to your computer and use it in GitHub Desktop.
I didn't run this, but it should be mostly correct.
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'; | |
class ExampleClass extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
isClicked: false; | |
}; | |
} | |
handleClick() { | |
this.setState({ | |
isClicked: !this.state.isClicked | |
}); | |
} | |
render() { | |
return ( | |
<div className='container'> | |
<div id='someElement' className={this.state.isClicked ? 'clicked' : ''}> | |
I'm an element. | |
</div> | |
<button id='someButton' onClick={this.handleClick}> | |
Click me! | |
</button> | |
</div> | |
); | |
} | |
}; | |
ReactDOM.render( | |
<ExampleClass />, | |
document.getElementById('content') | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment