Skip to content

Commit 14a106f

Browse files
committed
Fix handling of option ssr:false to work like not setting ssr option at all
1 parent 2f576fc commit 14a106f

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ export function useStore(store, { keys, deps = [store, keys], ssr } = {}) {
2424
return useSyncExternalStore(
2525
subscribe,
2626
get,
27-
ssr === true ? () => store.init : (ssr ?? get)
27+
ssr === true ? () => store.init : ssr || get
2828
)
2929
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
"index.js": "{ useStore }",
9393
"nanostores": "{ map, computed }"
9494
},
95-
"limit": "939 B"
95+
"limit": "940 B"
9696
}
9797
]
9898
}

test/index.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,11 @@ test('support for SSR does not break server behaviour in non-SSR projects', () =
261261
let mapValues: Value[] = [] // Track values used across renders
262262

263263
let MapTest: FC = () => {
264-
let value = useStore(mapStore).value
264+
let value = useStore(
265+
mapStore,
266+
// Setting `ssr:false` should be equivalent to not setting `ssr` at all
267+
{ ssr: false }
268+
).value
265269
mapValues.push(value)
266270
return h('div', { 'data-testid': 'map-test' }, value)
267271
}

0 commit comments

Comments
 (0)