Closed ampcpmgp closed 4 months ago
The following code is assumed in non-SSR.
// atoms
const eventAtom = atom<Event | null>(null)
// How to use provider
functtion Events () {
return (
<>
{events.map(item => (
// default value is null
<ScopeProvider atoms={[eventAtom]}>
// set initial value
<?? initialuValue={item}>
<Event />
</??>
</ScopeProvider>
)}
</>
)
}
// How to use scoped atom
function Event () {
const [event] = useAtom(eventAtom)
return (
<div>
// I want to remove optional and type-safe, if possible.
<span>title: {event?.name}</span>
</div>
)
}
You can use useHydrateAtoms
without SSR.
有難うございます!
I found useHydrateAtoms in the documentation, but since it is in the SSR section, I wasn't sure if it was available when not using SSR.
https://jotai.org/docs/utilities/ssr
Is there any problem to use it when non-SSR?