function useCallbackRef() {
const [domElem, setDomElem] = React.useState(null);
function setElem(elem) {
if (elem) {
setDomElem(elem);
setDomElem.current = elem; // This is important , because might be some other component which will be needing
// access to the elem
}
}
return [domElem, setElem];
}
blog11.md
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment