Skip to content

Commit

Permalink
docs(useLocalStorageValue & useSessionStorageValue): Fix mixed info o…
Browse files Browse the repository at this point in the history
…n initializeWithValue

Previously the docs would imply in the top part that initializeWithValue was false by default, which
is not the case.
  • Loading branch information
ArttuOll committed Nov 4, 2022
1 parent 92aa184 commit 81711e2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
1 change: 0 additions & 1 deletion src/useLocalStorageValue/__docs__/example.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export const Example: React.FC<ExampleProps> = ({
}) => {
const lsVal = useLocalStorageValue(key, {
defaultValue,
initializeWithValue: true,
});

return (
Expand Down
11 changes: 6 additions & 5 deletions src/useLocalStorageValue/__docs__/story.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Example } from './example.stories'
import { ImportPath } from '../../__docs__/ImportPath'
import { ArgsTable, Canvas, Meta, Story } from '@storybook/addon-docs'
import {Example} from './example.stories'
import {ImportPath} from '../../__docs__/ImportPath'
import {ArgsTable, Canvas, Meta, Story} from '@storybook/addon-docs'

<Meta title="Side-effect/useLocalStorageValue" component={Example} />

Expand All @@ -18,8 +18,9 @@ Manages a single LocalStorage key.
> Does not allow usage of `null` value, since JSON allows serializing `null` values - it would be
> impossible to separate null value fom 'no such value' API result which is also `null`.
> Due to support of SSR this hook returns undefined on first render even if value is there, to avoid
> this behavior set the `initializeWithValue` option to true.
> If you are doing SSR, set `initializeWithValue` to `false` in order for this hook to return
> `undefined` on first render. The LocalStorage value will be fetched client-side when effects
> are executed.
#### Example

Expand Down
2 changes: 1 addition & 1 deletion src/useSessionStorageValue/__docs__/example.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const Example: React.FC<ExampleProps> = ({
key = 'react-hookz-ss-test',
defaultValue = '@react-hookz is awesome',
}) => {
const ssVal = useSessionStorageValue(key, { defaultValue, initializeWithValue: true });
const ssVal = useSessionStorageValue(key, { defaultValue });

return (
<div>
Expand Down
11 changes: 6 additions & 5 deletions src/useSessionStorageValue/__docs__/story.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Example } from './example.stories'
import { ImportPath } from '../../__docs__/ImportPath'
import { ArgsTable, Canvas, Meta, Story } from '@storybook/addon-docs'
import {Example} from './example.stories'
import {ImportPath} from '../../__docs__/ImportPath'
import {ArgsTable, Canvas, Meta, Story} from '@storybook/addon-docs'

<Meta title="Side-effect/useSessionStorageValue" component={Example} />

Expand All @@ -18,8 +18,9 @@ Manages a single SessionStorage key.
> Does not allow usage of `null` value, since JSON allows serializing `null` values - it would be
> impossible to separate null value fom 'no such value' API result which is also `null`.
> Due to support of SSR this hook returns undefined on first render even if value is there, to avoid
> this behavior set the `initializeWithValue` option to true.
> If you are doing SSR, set `initializeWithValue` to `false` in order for this hook to return
> `undefined` on first render. The SessionStorage value will be fetched client-side when effects
> are executed.
#### Example

Expand Down

0 comments on commit 81711e2

Please sign in to comment.