facebook/react-devtools

Move hooks inspection into the renderer

Closed this issue · 1 comments

Move the event creation for hooks inspection into the renderer.

I'm currently trying to add support for hooks in the devtools adapter for preact and I'm running into the issue that this code comment already describes:

// HACK: This leaks Fiber-specific logic into the Agent which is not ideal.
// $FlowFixMe
const currentFiber = data.state === internalInstance.memoizedState ? internalInstance : internalInstance.alternate;
const hooksTree = inspectHooksOfFiber(currentFiber, internals.currentDispatcherRef);

The Agent does the hook inspection itself instead of delegating it to the renderer like for all other events. Instead it should make a call to the attached renderer and thus move the responsibility of the event creation back to the renderer. Something like:

renderer.onHooksInspect(data, internals.currentDispatchRef);

I've spent the past days getting Preact in shape for the next devtools version and it fixes this issue. It does now asks the renderer to supply the necessary data which is super awesome 👍 Closing this issue, as it will be automatically fixed once the new devtools are marked as stable 💯