Recoil - single atom vs multiple atoms

Viewed 21

I have an index file that contains a lot of atoms for a wizard I've created.

I thought about moving all the creations -

export const foo1State = atom<string>({
    key: "foo1State",
    default: "",
});
export const foo2State = atom<boolean>({
    key: "foo2State",
    default: false,
});

into one using JSON -

    export const fooStates = atom<fooState>({
        key: "fooStates",
        default: {
                     foo1State: string = "",
                     foo2State: boolean = false,
                  }
     });

Is that a better approach? I'll mention that all that inputs are changing frequently so need to consider the renders.

What do you think?

Thanks

0 Answers
Related