Skip to content

Instantly share code, notes, and snippets.

@jamesplease jamesplease/

Last active May 17, 2019
What would you like to do?
Which custom hook + ref API do you prefer?


The hook creates and returns the ref.

const { ref, ...otherStuff } = useCustomHook();

return <div ref={ref} />


You create the ref, and then you pass it into the hook.

const ref = useRef();
const stuff = useCustomHook({ ref });

return <div ref={ref} />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.