Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sample code for a blog post about Optimizing Performance in React 18.6
import React from "react";
const BigGrid = ({ number }) => {
...
};
export default React.memo(BigGrid);
const BigGrid = ({ numbers }) => {
...
};
<BigGrid numbers={[firstNumber, secondNumber]} />
const numbers = React.useMemo(() => [firstNumber, secondNumber], [firstNumber, secondNumber]);
<BigGrid numbers={numbers} />
const [x, setX] = useState(1);
const logX = useCallback(() => console.log(x), [x]);
return <SomeComponent onClick={logX} />
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