Skip to content

Commit

Permalink
Docs: update SSR and Query docs to include notes about TS and useHydr…
Browse files Browse the repository at this point in the history
…ateAtom (#2882)

* Add Typescript note to Query Client example

* docs: add ts instructions for useHydrateAtoms to query and ssr

---------

Co-authored-by: Daishi Kato <[email protected]>
  • Loading branch information
rainagalbiati-turngate and dai-shi authored Dec 22, 2024
1 parent 7883c4e commit 1d5ba26
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/extensions/query.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ Although they reference methods same query key (`'todos'`), the `onSuccess` inva

This will result in `todosAtom` showing stale data as it was not prompted to refetch.

⚠️ Note: When using **Typescript**, it is recommended to use a Map when passing the queryClient value to useHydrateAtoms. You can find a working example in the [Initializing State on Render docs](https://jotai.org/docs/guides/initialize-atom-on-render#using-typescript)

```jsx
import { Provider } from 'jotai/react'
import { useHydrateAtoms } from 'jotai/react/utils'
Expand Down
2 changes: 2 additions & 0 deletions docs/utilities/ssr.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ useHydrateAtoms([
] as const)
```

Or you may need to use a Map when passing the atom value to useHydrateAtoms. You can find a working example in the [Initializing State on Render docs](https://jotai.org/docs/guides/initialize-atom-on-render#using-typescript).

### Demo

<Stackblitz id="stackblitz-starters-b7cvxi" file="pages%2Findex.tsx" />
Expand Down

0 comments on commit 1d5ba26

Please sign in to comment.