Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
yisar committed Jun 12, 2023
1 parent 186a630 commit 641d1de
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fre",
"version": "2.6.4",
"version": "2.6.5",
"type": "module",
"main": "dist/fre.js",
"unpkg": "dist/fre.umd.js",
Expand Down
7 changes: 5 additions & 2 deletions src/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,15 @@ export const useReducer = <S, A>(
if (hook.length === 0) {
hook[0] = initState
hook[1] = (value: A | Dispatch<A>) => {
hook[0] = reducer
let v = reducer
? reducer(hook[0], value as any)
: isFn(value)
? value(hook[0])
: value
update(current)
if (hook[0] !== v) {
hook[0] = v
update(current)
}
}
}
return hook
Expand Down

0 comments on commit 641d1de

Please sign in to comment.