Skip to content

Commit a2235c9

Browse files
authored
Merge pull request #382 from wooloo26/master
fix: resolve old fiber update caused by closure capture
2 parents 49a0717 + 824c807 commit a2235c9

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/hook.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ export const useReducer = <S, A>(
3333
const [hook, current] = getHook<HookReducer>(cursor++)
3434
if (hook.length === 0) {
3535
hook[0] = initState
36-
hook[1] = (value: A | Dispatch<A>) => {
37-
let v = reducer
38-
? reducer(hook[0], value as any)
39-
: isFn(value)
40-
? value(hook[0])
41-
: value
42-
if (hook[0] !== v) {
43-
hook[0] = v
44-
update(current)
45-
}
36+
}
37+
hook[1] = (value: A | Dispatch<A>) => {
38+
let v = reducer
39+
? reducer(hook[0], value as any)
40+
: isFn(value)
41+
? value(hook[0])
42+
: value
43+
if (hook[0] !== v) {
44+
hook[0] = v
45+
update(current)
4646
}
4747
}
4848
return hook as Required<HookReducer>

0 commit comments

Comments
 (0)