troch / reinspect

Use redux devtools to inspect useState and useReducer :mag_right:
MIT License
424 stars 24 forks source link

Do not call React hooks inside other hooks or conditions #4

Closed iagobruno closed 5 years ago

iagobruno commented 5 years ago

My app is complaining in the console about a hooks error:

image

But I went to investigate and my components are following the rules for hooks described in the React documentation. I looked deeper and I discovered that the errors are in your package, specifically in these lines:

https://github.com/troch/reinspect/blob/4f3a562ae0d6bf6ee9198362b21d224a304315d5/src/useReducer.ts#L71-L74

https://github.com/troch/reinspect/blob/4f3a562ae0d6bf6ee9198362b21d224a304315d5/src/useState.ts#L12-L15

https://github.com/troch/reinspect/blob/e682221e0336df10a51ff9c7e1c24c7054c3b1fb/src/useState.ts#L18-L20

https://github.com/troch/reinspect/blob/e682221e0336df10a51ff9c7e1c24c7054c3b1fb/src/useReducer.ts#L77-L79

I tried to fix it for you but you're going to have to rewrite a part of the code.

troch commented 5 years ago

Hello, should be fixed now with v1.0.0 (warning appeared in v16.8.0 of React).