Skip to content

Commit

Permalink
fix: previous value diff check
Browse files Browse the repository at this point in the history
  • Loading branch information
natalystx committed May 12, 2024
1 parent 70a8d83 commit c75429a
Show file tree
Hide file tree
Showing 2 changed files with 3 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": "shimmershards",
"version": "0.3.5",
"version": "0.3.6",
"description": "shimmershards is a reactive state library",
"main": "dist/index.js",
"module": "dist/index.es.js",
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useShard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export const useShard = <Type>(shard: Shard<Type>): State<Type> => {
if (publishers.get(id)?.getRecentlyData()) {
setState(publishers.get(id)?.getRecentlyData());
}
const subscribe = publishers.get(id)?.subscribe((v) => {

const subscribe = publishers.get(id)?.subscribe((v: Type) => {
setState(v);
});

Expand All @@ -37,7 +38,6 @@ export const useShard = <Type>(shard: Shard<Type>): State<Type> => {
return [
state,
(v: Type | PrevFn<Type>): void => {
if (v === state) return;
if (typeof v === "function") {
const newValue = (v as unknown as Function)(state) as Type;
publishers.get(id)?.publish(newValue);
Expand Down

0 comments on commit c75429a

Please sign in to comment.