Created
July 23, 2019 00:11
-
-
Save will-wow/389cda0b3fd48fecf470a5f06fa61ee6 to your computer and use it in GitHub Desktop.
Sample code for a blog post about Optimizing Performance in React 18.6
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
import React from "react"; | |
const BigGrid = ({ number }) => { | |
... | |
}; | |
export default React.memo(BigGrid); |
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 BigGrid = ({ numbers }) => { | |
... | |
}; |
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
<BigGrid numbers={[firstNumber, secondNumber]} /> |
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 numbers = React.useMemo(() => [firstNumber, secondNumber], [firstNumber, secondNumber]); | |
<BigGrid numbers={numbers} /> |
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 [x, setX] = useState(1); | |
const logX = useCallback(() => console.log(x), [x]); | |
return <SomeComponent onClick={logX} /> |
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 numbers = React.useMemo(() => [firstNumber, secondNumber], [firstNumber, secondNumber]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment