-
Notifications
You must be signed in to change notification settings - Fork 103
React Devtools are crashing when selecting a Component using a redux-react hook. #34
Comments
@bvaughn are we doing something bad with this custom hook, or is there a bug in the devtools? |
I have been similar situation with this custom hook. I believe is bug into devtools. I tried use this case with other similar hooks and they same influence to devtools. |
Where's a repro that I can run? If there's a bug triggered by DevTools, it's likely caused by the I would initially be suspicious of this async But it looks like there is no async code in the second error stack. Anyway. Repro please. |
Yeah it only happens when I use the useCallback function. I thought it's in combination with the redux hooks. |
I'll take a look, but only if you point me at a Code Sandbox where I can reproduce the problem. (I get pinged on a lot of issues. I don't generally have the time to figure out how to repro them.) |
Here is a sandbox: Note: Maybe it's something with React itself. |
Thanks for sharing the repro! This is interesting. Initially, I suspected the function useState<S>(
initialState: (() => S) | S,
): [S, Dispatch<BasicStateAction<S>>] {
let hook = nextHook();
let state: S =
hook !== null // 👈 this isn't null
? hook.memoizedState // 👈 but this is
: typeof initialState === 'function'
? initialState()
: initialState;
hookLog.push({primitive: 'State', stackError: new Error(), value: state});
return [state, (action: BasicStateAction<S>) => {}];
} I think that's because it's the wrong type of hook. Looks like this call to The Fiber's expected sequence of hooks is: callback, context, state, ref (x3), effect Bah! Looks like it's because Edit I need to dig a bit more. I can't reproduce this behavior when run as a local test. Will look into it more (perhaps not until Monday though) and report back! |
Good that my code could help you figuring out the issue! |
This turned out to be a bit more complex than it seemed at first glance. (See facebook/react#14940 (comment)).) We have a couple of possible fixes. Waiting on some others to weigh in before proceeding. |
Thanks for keeping us updated. I'll look into the PR to see more informations! |
FYI the fix facebook/react/pull/14940 has landed, but won't be useful until the next React release. |
Thank you alot @bvaughn! |
The fix for this issue was released with v16.8.4 |
It's not clear that this is the same error we're talking about, since the code you show above accepts |
I experienced crashes with my application when using the provided hooks.
When I try to inspect a component using the useMappedState hook, the application will crash with the following error:
My code implementation for the name component:
looks like the devtools don't know how to interpret the value of the mapped state. Anyone else experienced issues like this?
The text was updated successfully, but these errors were encountered: