Skip to content

Commit

Permalink
remove unintended change from default merge behaviour to identical bu…
Browse files Browse the repository at this point in the history
…t manual one (#2661)

targeted section of the README talks about integration with redux devtools. to accomplish this the dev needs to define third argument for `set` function. since arguments for `set` function are positional it means he/she needs to define the second, `replace`, argument as well

currently README suggests just to use `false` value for `replace` arg i.e. to override the default value by identical manual one, but defined on the dev side.

more clean way would be to use `undefined` at the second argument position that will make JS to use the default value, that is defined by lib authors, not dev
  • Loading branch information
vorant94 authored Aug 4, 2024
1 parent 66f3a02 commit 7c14615
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ const useBearStore = create(devtools((set) => ({
...
eatFish: () => set(
(prev) => ({ fishes: prev.fishes > 1 ? prev.fishes - 1 : 0 }),
false,
undefined,
'bear/eatFish'
),
...
Expand All @@ -413,7 +413,7 @@ You can also log the action's type along with its payload:
...
addFishes: (count) => set(
(prev) => ({ fishes: prev.fishes + count }),
false,
undefined,
{ type: 'bear/addFishes', count, }
),
...
Expand Down

0 comments on commit 7c14615

Please sign in to comment.