How to use the generated refs?
alexej-d opened this issue · 2 comments
alexej-d commented
What if one needs to reuse the generated refference's ref for another effect like this https://streamich.github.io/react-use/?path=/story/ui-useclickaway--docs?
As I see, refference.ref and popper.ref are just functions so it is not possible to access their current prop from outside to target the DOM element.
sandiiarov commented
I am using mergeRefs helper
function mergeRefs(...refs) {
return ref => {
refs.forEach(resolvableRef => {
if (typeof resolvableRef === 'function') {
resolvableRef(ref);
}
if (resolvableRef) {
resolvableRef.current = ref;
}
});
};
}
alexej-d commented
Great, didn't know this was possible, thanks!