Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

DevTools: hooks with numbers, strings or booleans show as undefined #16859

Closed
cxcorp opened this issue Sep 23, 2019 · 6 comments · Fixed by #16867
Closed

DevTools: hooks with numbers, strings or booleans show as undefined #16859

cxcorp opened this issue Sep 23, 2019 · 6 comments · Fixed by #16867

Comments

@cxcorp
Copy link

cxcorp commented Sep 23, 2019

Do you want to request a feature or report a bug?
Report a bug

What is the current behavior?
The useState hook's value is shown as undefined in React DevTools if the value is a string or a number. Clicking on the bug icon prints the correct values to console.

image

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React.
CodeSandbox: https://codesandbox.io/s/keen-colden-syb7r
Direct link to page so you can see the DevTools: https://2km9v.csb.app/

What is the expected behavior?
The DevTools should show the correct value of the hook.

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
React 16.9.0.
Google Chrome [Version 77.0.3865.90 (Official Build) (64-bit)] running on Linux x64.

This issue appeared after version 4.1.0 (9/19/2019) of the DevTools Chrome extension.

Might be same bug as #16843 but this one appears without any complicated reproduction steps.

@cxcorp cxcorp changed the title DevTools: hooks with numbers or strings show as undefined DevTools: hooks with numbers, strings or booleans show as undefined Sep 23, 2019
@cxcorp
Copy link
Author

cxcorp commented Sep 23, 2019

Looks like the issue also appears with boolean values.

@arkuar
Copy link

arkuar commented Sep 23, 2019

Having the same problem.
The extension worked fine after I downgraded React to version 16.8.6

@bvaughn
Copy link
Contributor

bvaughn commented Sep 23, 2019

I think the only significant difference between React v16.8 and v16.9 is that v16.9 injects the overrideHookState function DevTools uses to support editable hooks (in other words, DevTools is using a different code path when you run v16.8 vs v16.9).

I think that means this bug is probably related to #16700 somehow. Will dig in more.

@bvaughn
Copy link
Contributor

bvaughn commented Sep 23, 2019

Should be fixed by #16867

@bvaughn
Copy link
Contributor

bvaughn commented Sep 23, 2019

This fix will be released with 4.1.1 (sometime soon)

ZakLaughton added a commit to ZakLaughton/survivor-stats that referenced this issue Sep 24, 2019
Due to this bug in devtools: facebook/react#16859
@bvaughn
Copy link
Contributor

bvaughn commented Sep 26, 2019

This fix has just been published to NPM and posted to Chrome/Firefox as v4.1.1

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants