Skip to content

Instantly share code, notes, and snippets.

@Sergioamjr
Last active May 22, 2021 15:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sergioamjr/04a6e054873f0a65b5a19653ef3473e3 to your computer and use it in GitHub Desktop.
Save Sergioamjr/04a6e054873f0a65b5a19653ef3473e3 to your computer and use it in GitHub Desktop.
import { useCallback } from "react";
export default function Parent() {
const doSomething = useCallback(() => {
// A função sempre terá a mesma referência.
}, []);
const doAnotherThingWithAandB = useCallback(() => {
// Sua referência irá mudar quando a e b mudarem.
}, [a, b]);
return(
<Component
doSomething={doSomething}
doAnotherThingWithAandB={doAnotherThingWithAandB}
/>;
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment