Error with undefined __hooks property
See original GitHub issueHi,
sorry for this confusing issue, but I haven’t found anything so far:
I have the issue that __hooks
is suddenly undefined:
Both of the forEach
before succeed, but here __hooks
is suddenly undefined (ie it must be through a side effect of one the invokeEffect
calls):
Error in console:
My hooks.module.js
(extended by some console.log()
calls):
I highlighted the one that is right before the error.
The component that is triggering this error seems innocent enough (it is not yet finished 😉):
Show screenshot
Happy to provide any additional info, if you could give me some pointers on where to look.
Issue Analytics
- State:
- Created 4 years ago
- Comments:15 (6 by maintainers)
Top Results From Across the Web
React hooks Cannot read properties of undefined using react
Any help is greatly appreciated . Uncaught TypeError: Cannot read properties of undefined (reading 'name'). const SignupSchema = yup.object ...
Read more >Uncaught TypeError: Cannot read properties of undefined ...
Hello. After the latest updates, I have this problem in the console. `Uncaught TypeError: Cannot read properties of undefined (reading 'hooks')
Read more >useeffect cannot read properties of undefined - You.com
When you encounter the "Cannot read property of undefined" error in the useEffect hook [1], it usually means that you are trying to...
Read more >useHooks - Easy to understand React Hook recipes
We bring you easy to understand React Hook code recipes so you can learn how React ... undefined, error: action.payload }; default: throw...
Read more >[accept Hook] - Cannot read property 'toBytesSink' of undefined
Hi, I am learning about Hooks and I wanted to try first with something simple and the "accept" hook. ... Have you already...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ok wow, so I finally got it reproducible. (I don’t want to admit that finding this just took me around 4.5 hours 😬)
Please, before investing time into “fixing this”: if my code / architecture is 💩 (ie that is a “won’t fix”), please tell me beforehand so that I can clean it up on my side and you don’t have to support super obscure use cases. 😬
Here is the reproducer: https://codesandbox.io/s/mystifying-frost-u6b7v
render()
) in an effect.I have absolutely no idea what is happening here, but what I can tell you is:
render()
code outside of theuseEffect
it works.I guess step 2 is not supposed to be done like this, but I actually have no idea anymore now 😄
@apfelbox I put up a PR that is aimed at fixing this issue. Sorry I totally missed that repro