I have 3 functional components and I'd like to pass & manipulate data through useRef
.
I am adding this onClose
method to current
property in one of my component.
const onClose = () => {
setButtonColor(buttonColor);
};
ref.current = {
clearSwitchStateOnClose: onClose,
};
I am calling that method in another component.
ref.current.clearSwitchStateOnClose();
I am receiving this error,
Uncaught TypeError: ref.current.clearSwitchStateOnClose is not a function