schiehll / react-alert

alerts for React
MIT License
607 stars 99 forks source link

Test cases getting failed on using useAlert() #179

Closed rakeshkk16 closed 3 years ago

rakeshkk16 commented 3 years ago

TypeError: Cannot read property 'current' of undefined

> 14 |     let alert = useAlert();

I am not using useRef in my component and test cases started failing only after adding this react alert.

Loorik commented 3 years ago

I have the exact same Error using Typescript, testing with Jest in a create-react-app bootstrap

metal450 commented 3 years ago

I have this issue too. did anyone solve it? usealert seems to be the only thing breaking my unit tests :/

metal450 commented 3 years ago

Actually, found the solution. It's here: https://github.com/schiehll/react-alert/issues/148

(wrap in AlertProvider)