Skip to content

Instantly share code, notes, and snippets.

Created December 25, 2019 15:59
What would you like to do?
function useCallbackRef() {
  const [domElem, setDomElem] = React.useState(null);
  function setElem(elem) {
    if (elem) {
      setDomElem.current = elem; // This is important , because might be some other component which will be needing
      // access to the elem
  return [domElem, setElem];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment