-
Notifications
You must be signed in to change notification settings - Fork 47.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DevTools Bug] When inspecting, hook values after useDeferredValue
are offset
#24623
Comments
Hi! I'm a little confused. Are you trying to say this issue only exists when you have devtools open? |
Yeah, it only happens when the dev tools inspect the hooks of a component. It also doesn't seem to affect the actual value of the hooks outside of the devtools, just what the devtools display (using the reprod as an example, if you make the text be `<p>{first}</p>` it renders the correct value)
|
I tried to create a repro on codesandbox with your code, but everything works fine https://codesandbox.io/s/angry-bush-ziik01?file=/src/App.js:390-413 Anything I missed? |
Interesting, that codesandbox works fine for me too, but running it through create-react-app causes the issue. Maybe codesandbox is doing something weird that somehow makes it work. I've just tested in Chromium (with dev tools 4.24.6-ca7a38ae4) and it has the same result - works in the codesandbox but not if I run the code with CRA. |
Looks like this issue exist with react 18.1.0 but not with react 18.0.0? |
I'm not sure - in the codesandbox that you created, if you set it to React 18 it has the issue (although the first memo in that case has no value and the second memo has the first memo's value). Although the codesandbox works fine in 18.1 so it might be a different issue. Using CRA though the issue doesn't happen with 18.0 |
#24247 changed its implementation in 18.1 which may be the reason. Maybe something needs to be adjusted. |
DevTools implementation assumes the old code: react/packages/react-debug-tools/src/ReactDebugHooks.js Lines 313 to 317 in 3133dfa
But there is just one work-in-progress hook in the new code. |
I'm not sure how but it seems like we'd need to either break it for 18.0 or add version check and advance the hook index depending on the version. I suggest to check with @acdlite. |
Nope, their dev tools calls nextHook() twice too |
Website or app
https://github.com/Alduino/React-useDeferredValue-DevTools-Reprod
Repro steps
3.14
(the value that the second Memo should have) instead of1.41
If you want it to throw an error instead of just looking at the values, you can set
window.throwIfIncorrect = true
before DevTools inspects the component.I tried in CodeSandbox's embedded React dev tools as well - the issue happens in React 18.0 (though the first hook has no value and the second has the first hook's value) but it doesn't happen in 18.1.
How often does this bug happen?
Every time
DevTools package (automated)
react-devtools-extensions
DevTools version (automated)
4.24.0-82762bea5
Error message (automated)
First is 3.14 when it should be 1.41
Error call stack (automated)
Error component stack (automated)
GitHub query string (automated)
The text was updated successfully, but these errors were encountered: