question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error with undefined __hooks property

See original GitHub issue

Hi,

sorry for this confusing issue, but I haven’t found anything so far:

I have the issue that __hooks is suddenly undefined: 2019-12-10 at 17 19

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: 2019-12-10 at 17 20

My hooks.module.js (extended by some console.log() calls): 2019-12-10 at 17 20

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

2019-12-10 at 17 23

Happy to provide any additional info, if you could give me some pointers on where to look.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:15 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
apfelboxcommented, Dec 10, 2019

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

  1. pass a state hook setter into a nested prop
  2. immediately call this setter synchronously
  3. in the inner element render something (somewhere else using render()) in an effect.

I have absolutely no idea what is happening here, but what I can tell you is:

  • if move the render() code outside of the useEffect it works.
  • if I remove the state hook setter call it works

I guess step 2 is not supposed to be done like this, but I actually have no idea anymore now 😄

2reactions
JoviDeCroockcommented, Apr 21, 2020

@apfelbox I put up a PR that is aimed at fixing this issue. Sorry I totally missed that repro

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found