Skip to content

Commit

Permalink
fix: static-store setValue with setterFn has correct arguments (#734)
Browse files Browse the repository at this point in the history
  • Loading branch information
thetarnav authored Jan 10, 2025
2 parents 71f6c5e + 56d9511 commit 415064d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/silent-paws-approve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@solid-primitives/static-store": patch
---

fix: static-store setValue with setterFn has correct arguments
2 changes: 1 addition & 1 deletion packages/static-store/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function createStaticStore<T extends object>(
const setValue = (key: keyof T, value: SetterParam<any>): void => {
const signal = cache[key];
if (signal) return signal[1](value);
if (key in copy) copy[key] = accessWith(value, [copy[key]]);
if (key in copy) copy[key] = accessWith(value, copy[key]);
};

return [
Expand Down
3 changes: 3 additions & 0 deletions packages/static-store/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ describe("createStaticStore", () => {
d: [0, 1, 2],
});

setState('a', prev => prev + 1);
expect(state.a).toBe(10);

createEffect(() => {
state.a;
aUpdates++;
Expand Down

0 comments on commit 415064d

Please sign in to comment.