Created
November 17, 2019 20:03
-
-
Save oshell/edc14611adc1a72f599574c26727e98d to your computer and use it in GitHub Desktop.
stateful functional component
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, { useState } from 'react'; | |
import './App.css'; | |
function App() { | |
const [color, changeColor] = useState('blue'); | |
return ( | |
<div className="App"> | |
<button onClick={changeColor.bind(null, 'blue')}>blue</button> | |
<button onClick={changeColor.bind(null, 'green')}>green</button> | |
<button onClick={changeColor.bind(null, 'red')}>red</button> | |
<div className={`box ${color}`}> | |
Lorem Ipsum | |
</div> | |
</div> | |
); | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment