Skip to content

Commit dd0a0b9

Browse files
feat(overmind-react): optimize for SSR
1 parent b69c8ac commit dd0a0b9

File tree

1 file changed

+11
-1
lines changed
  • packages/node_modules/overmind-react/src

1 file changed

+11
-1
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {
22
IConfiguration,
3-
IContext,
3+
MODE_SSR,
44
EventType,
55
Overmind,
66
OvermindMock,
@@ -86,6 +86,16 @@ export const createHook = <Config extends IConfiguration>(
8686
const overmind = (overmindInstance || useContext(context)) as Overmind<
8787
Config
8888
>
89+
90+
if ((overmind as any).mode === MODE_SSR) {
91+
return {
92+
state: overmind.state,
93+
actions: overmind.actions,
94+
effects: overmind.effects,
95+
addMutationListener: overmind.addMutationListener,
96+
}
97+
}
98+
8999
const component = useCurrentComponent()
90100
const name = component.name
91101
component.__componentId =

0 commit comments

Comments
 (0)