Closed bgergen closed 2 years ago
Neat! Hadn't thought of using the debug hook. Do you have a screenshot of what this looks like in the devtools?
@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.
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:
useTracking
hook because it makes it more discoverable. Otherwise, devs would need to inspect the nesteduseTrackingImpl
hook in order to discover it. I added it also touseTrackingImpl
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 theuseTrackingImpl
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