Skip to content

Commit b8a4272

Browse files
committed
fix(overmind-react): createHook effect, check if overmindState has a value
1 parent 5d3d9be commit b8a4272

File tree

1 file changed

+8
-6
lines changed
  • packages/node_modules/overmind-react/src

1 file changed

+8
-6
lines changed

packages/node_modules/overmind-react/src/index.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,14 @@ export const createHook = <A extends Overmind<Configuration>>(overmind: A) => {
8888
useEffect(
8989
() => {
9090
return () => {
91-
overmind.eventHub.emitAsync(EventType.COMPONENT_REMOVE, {
92-
componentId: component.__componentId,
93-
componentInstanceId: overmindState.componentInstanceId,
94-
name,
95-
})
96-
overmindState.listener.dispose()
91+
if (overmindState) {
92+
overmind.eventHub.emitAsync(EventType.COMPONENT_REMOVE, {
93+
componentId: component.__componentId,
94+
componentInstanceId: overmindState.componentInstanceId,
95+
name,
96+
})
97+
overmindState.listener.dispose()
98+
}
9799
}
98100
},
99101
[component.__componentId]

0 commit comments

Comments
 (0)