Skip to content
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

Bug(devtools): complex types ignored sometimes in useDebugValue #17955

Closed
eps1lon opened this issue Feb 1, 2020 · 18 comments · Fixed by #18070
Closed

Bug(devtools): complex types ignored sometimes in useDebugValue #17955

eps1lon opened this issue Feb 1, 2020 · 18 comments · Fixed by #18070
Assignees
Labels
Component: Developer Tools good first issue (taken) Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug

Comments

@eps1lon
Copy link
Collaborator

eps1lon commented Feb 1, 2020

React version: 0.0.0-241c4467e (current next) and 16.12.0
Devtools: 4.4.0 (1/3/2020). [...] Created from revision f749045 on 1/3/2020.

Steps To Reproduce

  1. Visit https://codesandbox.io/s/usedebugvalue-complex-types-3x877
  2. Inspect App Component
  3. NoHooksAtAll displays no hooks at all
  4. IgnoredComplexValue displayes the custom hook but without a value
  5. NoHooksAtAll displays the custom hook with its value

Link to code example:

The current behavior

Complex values (and custom hooks) are sometimes not displayed

The expected behavior

Implementation of components and hooks should not affect if these are displayed.

@wfnuser
Copy link
Contributor

wfnuser commented Feb 3, 2020

I would like to take a look. 😄

@bvaughn
Copy link
Collaborator

bvaughn commented Feb 3, 2020

This issue is all yours! 😄

I've added the "good first issue (taken)" label so that others will know not to start work on the issue. If you change your mind about the issue, no worries! Just let me know so that I can remove the label and free it up for someone else to claim.

Cheers!

@wfnuser
Copy link
Contributor

wfnuser commented Feb 4, 2020

Thanks. I'm working on it.

@wfnuser
Copy link
Contributor

wfnuser commented Feb 16, 2020

Hi... It seems I need some help... I'm not sure what the hooks should behave in the dev-tools.
Would anyone explain it more detailed for me. Or give me some docs to follow... It has proved that I'm still very new to react.😅
image

@bvaughn
Copy link
Collaborator

bvaughn commented Feb 16, 2020

@wfnuser I don't think I understand what you're asking.

@eps1lon
Copy link
Collaborator Author

eps1lon commented Feb 17, 2020

@wfnuser
Here's a mock of what I would've expected looking at the built-in hooks.

currently working as expected

currently working useDebugValue in component

DisplayedComplexValuePass

missing debug value in component

actual

IgnoredComplexValueFail

expected

IgnoredComplexValuePass

missing hooks in component

actual

NoHooksAtAllFail

expected

NoHooksAtAllPass

@bvaughn needs to confirm if this is correct.

I can write some tests tomorrow if you're not sure where to start. Having failing test might help experimenting with various pieces of code to see what does what.

@wfnuser
Copy link
Contributor

wfnuser commented Feb 17, 2020

@wfnuser
Here's a mock of what I would've expected looking at the built-in hooks.

currently working as expected

currently working useDebugValue in component

missing debug value in component

actual
IgnoredComplexValueFail

expected
IgnoredComplexValuePass

missing hooks in component

actual
NoHooksAtAllFail

expected
NoHooksAtAllPass

@bvaughn needs to confirm if this is correct.

I can write some tests tomorrow if you're not sure where to start. Having failing test might help experimenting with various pieces of code to see what does what.

Thanks a lot. I still need to learn more about how hooks work. If you can provide some tests, that will be very helpful.

@bvaughn
Copy link
Collaborator

bvaughn commented Feb 18, 2020

Not sure if I agree with "no hooks at all" component. Seems like a use case that I'm not sure if DevTools needs to support.

@eps1lon
Copy link
Collaborator Author

eps1lon commented Feb 18, 2020

Seems like a use case that I'm not sure if DevTools needs to support.

Because there are no built-in hooks used other than useDebugValue? Would probably agree with that. It's still surprising behavior which I'd like to avoid generally.

@eps1lon
Copy link
Collaborator Author

eps1lon commented Feb 18, 2020

@bvaughn I'm quite lost where the tests for these components are located. The data seems to be wired up correctly. It looks like the view is not working but I can't find tests for those. Is there some documentation how to test devtools?

@bvaughn
Copy link
Collaborator

bvaughn commented Feb 18, 2020

Seems like a use case that I'm not sure if DevTools needs to support.

Because there are no built-in hooks used other than useDebugValue? Would probably agree with that. It's still surprising behavior which I'd like to avoid generally.

Yes. There's no need to use such a hook at all, since hooks calls can't be conditional to begin with (without leading to errors).

@bvaughn I'm quite lost where the tests for these components are located. The data seems to be wired up correctly. It looks like the view is not working but I can't find tests for those.

You'd probably want to add tests to the following places:

Is there some documentation how to test devtools?

No.

@eps1lon
Copy link
Collaborator Author

eps1lon commented Feb 18, 2020

Ah I couldn't get it pick up react-devtools-shared but this isn't included in yarn test. yarn test-build-devtools was the magic word.

@eps1lon
Copy link
Collaborator Author

eps1lon commented Feb 18, 2020

Yes. There's no need to use such a hook at all, since hooks calls can't be conditional to begin with (without leading to errors).

Just to be clear: There's not conditional call there. It's just not using an built-in hooks other than useDebugValue

@bvaughn
Copy link
Collaborator

bvaughn commented Feb 18, 2020

Yes. There's no need to use such a hook at all, since hooks calls can't be conditional to begin with (without leading to errors).

Just to be clear: There's not conditional call there. It's just not using an built-in hooks other than useDebugValue

I understand. My point though is that- since hooks calls can't be conditional, this could only ever be an "empty" hook- which serves no purpose and so I don't see it as a use case we should ever need to support.

@eps1lon
Copy link
Collaborator Author

eps1lon commented Feb 18, 2020

My point though is that- since hooks calls can't be conditional, this could only ever be an "empty" hook- which serves no purpose and so I don't see it as a use case we should ever need to support.

I'm confused. A custom hook with no built-in hooks is the only hook that's displaying complext types. It's only not working for the component that doesn't use built-in hooks (other than useDebugValue) at all.

As soon as a custom hook uses useDebugValue and built-in hooks the complex type isn't displayed.

@bvaughn
Copy link
Collaborator

bvaughn commented Feb 18, 2020

I'm not sure where the confusion is.

I'm just saying that the "no hooks at all" component is not a use case I care about us supporting, because that's a "custom hook" that literally only uses the debug value hook and nothing else. That use case is not important to support. (If it works, fine. If it doesn't work, fine.)

@eps1lon
Copy link
Collaborator Author

eps1lon commented Feb 19, 2020

I'm not sure where the confusion is.

I originally thought at least something is working. But since we don't care about the case that is working it's a bit more complicate to understand for an outside contributor how to create a test and feature since I have nothing to work off.

@eps1lon
Copy link
Collaborator Author

eps1lon commented Feb 19, 2020

@wfnuser This was more complicated than I thought #18070 already includes a fix. I wasn't able to write test and fix separately, sorry. Might still make sense to check #18070 out in case the fix isn't accepted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Developer Tools good first issue (taken) Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants