jotai-form icon indicating copy to clipboard operation
jotai-form copied to clipboard

input starts dirty when hydrated

Open jrnxf opened this issue 3 months ago • 5 comments

If I have an atom defined like this

export const nameAtom = atomWithValidate("", {
  validate: (name) => {
    try {
      name.parse(name);
      return name;
    } catch (err: any) {
      throw err.issues;
    }
  },
});

and hydrate it via

useHydrateAtoms([[nameAtom, "hello world"]);

the input will start as dirty, since "hello world" !== "". If an atom is hydrated, what it is hydrated with should be the initial value that is checked against to determine if the input is dirty or not.

jrnxf avatar Mar 24 '24 08:03 jrnxf