Skip to content

Commit fc1e76a

Browse files
fix(overmind): fix illegael invocation on effect proxies
1 parent be63e57 commit fc1e76a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/node_modules/overmind/src/proxyfyEffects.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function isObject(value) {
66

77
let hasWarnedConstructor = false
88
let currentEffectId = 0
9-
9+
const ORIGIN_TARGET = Symbol('ORIGIN_TARGET')
1010
export function proxifyEffects<Effects>(
1111
effects: Effects,
1212
cb: (effect) => void,
@@ -22,7 +22,7 @@ export function proxifyEffects<Effects>(
2222
const name = path.split('.')
2323
const method = name.pop()
2424
return cb({
25-
func: target.bind(thisArg),
25+
func: target.bind(thisArg[ORIGIN_TARGET]),
2626
effectId,
2727
name: name.join('.'),
2828
method,
@@ -40,6 +40,10 @@ export function proxifyEffects<Effects>(
4040
return new Target(...args)
4141
},
4242
get(target, prop) {
43+
if (prop === ORIGIN_TARGET) {
44+
return target
45+
}
46+
4347
return proxifyEffects(target[prop], cb, path ? path + '.' + prop.toString() : prop.toString())
4448
}
4549
})

0 commit comments

Comments
 (0)