schiehll / react-alert

alerts for React
MIT License
607 stars 99 forks source link

lib broken #112

Closed FabianoLothor closed 5 years ago

FabianoLothor commented 5 years ago

https://codesandbox.io/s/y254w5oznx

useAlert() hook is not working, returning undefined.

schiehll commented 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?

FabianoLothor commented 5 years ago

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.

schiehll commented 5 years ago

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.