-
-
Notifications
You must be signed in to change notification settings - Fork 678
Closed
Labels
has snippetThis issue includes code snipppets as solutions or workaroundsThis issue includes code snipppets as solutions or workarounds
Description
Currently the most issue I see with atoms is initial atom state which especially on server cant be inside any global objects ie localStorage etc. (setEffect is not working on server too)
Creating atoms and passing them through a context - loss of main advantages (u would need to create dependent atoms in context etc)
Probably passing Provider value to atom on initial call could solve this?
I.e.
// atom already have getter fn as param so I call atom with state dependent on context subatom.
const myAtom = subatom(ctx => ctx.someVal)
....
// in some component
<InitialJotaiValueProvider value={{ someVal: 123 }}> ...
Or probably some other beautiful api can be available.
PS: Api like above can be typed well like
const { InitialValueProvider, subatom} = createBlaBla<ValueType>()
Metadata
Metadata
Assignees
Labels
has snippetThis issue includes code snipppets as solutions or workaroundsThis issue includes code snipppets as solutions or workarounds