Closed FabianoLothor closed 5 years ago
You have to have a Provider in a parent component before using the hook. Take a look in this example.
See how the App
has a Provider and the Home
is the one using the hook?
I have a Project A and a Project B.
Project B uses the Project A components.
In my project A I'm exporting the react-alert components.
I have a Provider in my Project B, but the useAlert hook returns undefined.
Without seeing your code I can't help, but I can assure you that if you have a Provider in a parent component, the useAlert
hook works.
If you can provide a codesandbox that reproduce your issue (the one you posted before doesn't have a Provider, so that's why it doesn't work) I can try to help.
https://codesandbox.io/s/y254w5oznx
useAlert() hook
is not working, returningundefined
.