Skip to content

Commit 2331937

Browse files
fix(overmind-react): fix typing related to context
1 parent cf80060 commit 2331937

File tree

1 file changed

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

1 file changed

+11
-18
lines changed

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

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {
22
ENVIRONMENT,
33
EventType,
4-
IConfiguration,
54
IContext,
65
IReaction,
76
MODE_SSR,
@@ -79,7 +78,7 @@ const useCurrentComponent = () => {
7978
: {}
8079
}
8180

82-
const useState = <Context extends IContext<IConfiguration>>(
81+
const useState = <Context extends IContext<{}>>(
8382
cb?: (state: Context['state']) => any
8483
): Context['state'] => {
8584
const overmind = react.useContext(context) as Overmind<any>
@@ -183,9 +182,7 @@ const useState = <Context extends IContext<IConfiguration>>(
183182
return state
184183
}
185184

186-
const useActions = <
187-
Context extends IContext<IConfiguration>
188-
>(): Context['actions'] => {
185+
const useActions = <Context extends IContext<{}>>(): Context['actions'] => {
189186
const overmind = react.useContext(context) as Overmind<any>
190187

191188
if (!(overmind as any).mode) {
@@ -195,9 +192,7 @@ const useActions = <
195192
return overmind.actions
196193
}
197194

198-
const useEffects = <
199-
Context extends IContext<IConfiguration>
200-
>(): Context['effects'] => {
195+
const useEffects = <Context extends IContext<{}>>(): Context['effects'] => {
201196
const overmind = react.useContext(context) as Overmind<any>
202197

203198
if (!(overmind as any).mode) {
@@ -207,9 +202,7 @@ const useEffects = <
207202
return overmind.effects
208203
}
209204

210-
const useReaction = <Context extends IContext<IConfiguration>>(): IReaction<
211-
Context
212-
> => {
205+
const useReaction = <Context extends IContext<{}>>(): IReaction<Context> => {
213206
const overmind = react.useContext(context) as Overmind<any>
214207

215208
if (!(overmind as any).mode) {
@@ -219,29 +212,29 @@ const useReaction = <Context extends IContext<IConfiguration>>(): IReaction<
219212
return overmind.reaction as any
220213
}
221214

222-
export interface StateHook<Context extends IContext<IConfiguration>> {
215+
export interface StateHook<Context extends IContext<{}>> {
223216
(): Context['state']
224217
<T>(cb?: (state: Context['state']) => T): T
225218
}
226219

227-
export const createStateHook: <
228-
Context extends IContext<IConfiguration>
229-
>() => StateHook<Context> = () => useState
220+
export const createStateHook: <Context extends IContext<{}>>() => StateHook<
221+
Context
222+
> = () => useState
230223

231224
export const createActionsHook: <
232-
Context extends IContext<IConfiguration>
225+
Context extends IContext<{}>
233226
>() => () => Context['actions'] = () => {
234227
return useActions as any
235228
}
236229

237230
export const createEffectsHook: <
238-
Context extends IContext<IConfiguration>
231+
Context extends IContext<{}>
239232
>() => () => Context['effects'] = () => {
240233
return useEffects as any
241234
}
242235

243236
export const createReactionHook: <
244-
Context extends IContext<IConfiguration>
237+
Context extends IContext<{}>
245238
>() => () => IReaction<Context> = () => {
246239
return useReaction as any
247240
}

0 commit comments

Comments
 (0)