Skip to content

Instantly share code, notes, and snippets.

@ohansemmanuel
Created April 13, 2019 09:11
Show Gist options
  • Save ohansemmanuel/3b90563fd4558968e1819d3dbf0338ed to your computer and use it in GitHub Desktop.
Save ohansemmanuel/3b90563fd4558968e1819d3dbf0338ed to your computer and use it in GitHub Desktop.
const App = () => {
const [age, setAge] = useState(99)
const handleClick = () => setAge(age + 1)
const someValue = "someValue"
return (
<div>
<Age age={age} handleClick={handleClick} />
<Instructions doSomething={useCallback(() => {
return someValue
}, [someValue])} />
</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 = memo((props) => {
return (
<div style={{ background: 'black', color: 'yellow', padding: "1rem" }}>
<p>Follow the instructions above as closely as possible</p>
</div>
)
})
render(<App />)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment