Skip to content

Commit

Permalink
fix(utils): atomWithReducer for jotai-scope (pmndrs#2351)
Browse files Browse the repository at this point in the history
  • Loading branch information
dai-shi authored Jan 24, 2024
1 parent e3e3965 commit d2ee6d5
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/vanilla/utils/atomWithReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ export function atomWithReducer<Value, Action>(
initialValue: Value,
reducer: (value: Value, action: Action) => Value,
) {
const anAtom: any = atom(initialValue, (get, set, action: Action) =>
set(anAtom, reducer(get(anAtom), action)),
)
return anAtom
return atom(initialValue, function (this: any, get, set, action: Action) {
set(this, reducer(get(this), action))
})
}

0 comments on commit d2ee6d5

Please sign in to comment.