Skip to content

Commit dfb0c6b

Browse files
committed
fix(overmind-react): add EventType.COMPONENT_ADD to make Devtools Components work
1 parent 35acfea commit dfb0c6b

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

packages/overmind-react/src/index.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,23 @@ const useState = <Context extends IContext<{ state: {} }>>(
118118
currentComponentInstanceId++
119119
)
120120

121+
React.useEffect(() => {
122+
overmind.eventHub.emitAsync(EventType.COMPONENT_ADD, {
123+
componentId: component.__componentId,
124+
componentInstanceId,
125+
name,
126+
paths: [],
127+
})
128+
129+
return () => {
130+
overmind.eventHub.emitAsync(EventType.COMPONENT_REMOVE, {
131+
componentId: component.__componentId,
132+
componentInstanceId,
133+
name,
134+
})
135+
}
136+
}, [])
137+
121138
React.useEffect(() => {
122139
overmind.eventHub.emitAsync(EventType.COMPONENT_UPDATE, {
123140
componentId: component.__componentId,
@@ -131,13 +148,6 @@ const useState = <Context extends IContext<{ state: {} }>>(
131148
})
132149

133150
return () => {
134-
overmind.eventHub.emitAsync(EventType.COMPONENT_UPDATE, {
135-
componentId: component.__componentId,
136-
componentInstanceId,
137-
name,
138-
paths: [],
139-
})
140-
141151
dispose()
142152
}
143153
}, [trackStateTree])

0 commit comments

Comments
 (0)