diff --git a/libs/horizon/src/external/devtools.ts b/libs/horizon/src/external/devtools.ts index 1bc367ba..959911d6 100644 --- a/libs/horizon/src/external/devtools.ts +++ b/libs/horizon/src/external/devtools.ts @@ -1,5 +1,5 @@ import { travelVNodeTree } from '../renderer/vnode/VNodeUtils'; -import { Hook, Reducer, Ref, Effect, CallBack } from '../renderer/hooks/HookType'; +import { Hook, Reducer, Ref, Effect, CallBack, Memo } from '../renderer/hooks/HookType'; import { VNode } from '../renderer/vnode/VNode'; import { launchUpdateFromVNode } from '../renderer/TreeBuilder'; import { DomComponent } from '../renderer/vnode/VNodeTags'; @@ -7,8 +7,9 @@ import { getElementTag } from '../renderer/vnode/VNodeCreator'; import { JSXElement } from '../renderer/Types'; const isEffectHook = (state: any): state is Effect => !!state.effect; -const isRefHook = (state: any): state is Ref => state.hasOwnProperty('current'); +const isRefHook = (state: any): state is Ref => Object.prototype.hasOwnProperty.call(state, 'current'); const isCallbackHook = (state: any): state is CallBack => state.func !== undefined; +const isMemokHook = (state: any): state is Memo => Object.prototype.hasOwnProperty.call(state, 'result'); export const helper = { travelVNodeTree: (rootVNode, fun, childFilter: ((node: VNode) => boolean) | null = null) => { @@ -20,6 +21,8 @@ export const helper = { if ((state as Reducer).trigger) { if ((state as Reducer).isUseState) { return { name: 'State', hIndex, value: (state as Reducer).stateValue }; + } else if ((state as Reducer).reducer) { + return { name: 'Reducer', hIndex, value: (state as Reducer).stateValue }; } } else if (isRefHook(state)) { return { name: 'Ref', hIndex, value: (state as Ref).current }; @@ -28,6 +31,8 @@ export const helper = { return { name, hIndex, value: (state as Effect).effect }; } else if (isCallbackHook(state)) { return { name:'Callback', hIndex, value: (state as CallBack).func }; + } else if (isMemokHook(state)) { + return { name:'Memo', hIndex, value: (state as Memo).result }; } return null; },