Unable to set atom inital value as object #2728
Unanswered
Kaijonsson
asked this question in
Q&A
Replies: 1 comment 5 replies
-
I think this is probably what you want: https://tsplay.dev/WKlxpw import { atom } from "jotai";
type Test = {
test?: string;
value?: boolean;
};
export const test = atom<Test>({}); |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Bug Description
I'm strugging with the very basic task to provide a type and an initial value to an atom.
it works perfectly fine when you have arrays or booleans. Simple types.
This works perfectly:
export const test = atom<string>('test')
But when creating an object with some values, breaks the typeing.
This example gives an error like this when trying to provide an initial value to the atom:
I don't know if i've missed something in the tutorial/docs?
Hope you find all that you need in this report.
All the best
/Kaijonsson
Reproduction Link
can be tested in any jotai project.
Beta Was this translation helpful? Give feedback.
All reactions