Created
April 13, 2019 09:16
-
-
Save ohansemmanuel/54f118fc41f2b98f82125bbeece91b08 to your computer and use it in GitHub Desktop.
This file contains 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
const App = () => { | |
const [age, setAge] = useState(99) | |
const handleClick = () => setAge(age + 1) | |
const someValue = { value: "someValue" } | |
const doSomething = () => { | |
return someValue | |
} | |
return ( | |
<div> | |
<Age age={age} handleClick={handleClick}/> | |
<Instructions doSomething={doSomething} /> | |
</div> | |
) | |
} | |
const Age = ({ age, handleClick }) => { | |
return ( | |
<div> | |
<div style={{ border: '2px', background: "papayawhip", padding: "1rem" }}> | |
Today I am {age} Years of Age | |
</div> | |
<pre> - click the button below 👇 </pre> | |
<button onClick={handleClick}>Get older! </button> | |
</div> | |
) | |
} | |
const Instructions = React.memo((props) => { | |
return ( | |
<div style={{ background: 'black', color: 'yellow', padding: "1rem" }}> | |
<p>Follow the instructions above as closely as possible</p> | |
</div> | |
) | |
}) | |
ReactDOM.render ( | |
<App /> | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment