Skip to content

Instantly share code, notes, and snippets.

@jamesplease jamesplease/api.md
Last active May 17, 2019

Embed
What would you like to do?
Which custom hook + ref API do you prefer?

A

The hook creates and returns the ref.

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

return <div ref={ref} />

B

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.