Skip to content

Conversation

@bgergen
Copy link
Collaborator

@bgergen bgergen commented Dec 30, 2021

We're taking advantage of React's useDebugValue hook here in order to display contextual tracking data when a user inspects the hook in React devtools. 2 open questions:

  1. Is there any other data internal to the library that would be useful to display here?
  2. Is it necessary for us to call this twice? I like having it in the higher-level useTracking hook because it makes it more discoverable. Otherwise, devs would need to inspect the nested useTrackingImpl hook in order to discover it. I added it also to useTrackingImpl because that makes it visible for components that are using the HoC rather than the hook, since that hook is shared between both. It's redundant, but covers both use cases. Def open to thoughts on this. Decided to remove from the useTrackingImpl hook—I don't think devs would expect to see it there for a component using the decorator so it probably wouldn't get much use.

Screenshot

Screen Shot 2022-01-06 at 6 03 23 PM

@tizmagik
Copy link
Collaborator

tizmagik commented Jan 6, 2022

Neat! Hadn't thought of using the debug hook. Do you have a screenshot of what this looks like in the devtools?

@bgergen
Copy link
Collaborator Author

bgergen commented Jan 6, 2022

@tizmagik Just added a screenshot! What's really nice about it is that the callback function only gets called if the user is inspecting the hooks in the devtools.

Copy link
Collaborator

@tizmagik tizmagik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That’s super cool, love this!

@tizmagik tizmagik merged commit e1552da into main Jan 7, 2022
@tizmagik tizmagik deleted the usedebugvalue branch January 7, 2022 00:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants