T
TanStack•3mo ago
foreign-sapphire

Form does not use initial values from async query result

3 Replies
multiple-amethyst
multiple-amethyst•3mo ago
that defaultState seems to not be correct. You would only need to rely on defaultValues in this case does the error continue to happen if you remove that?
foreign-sapphire
foreign-sapphireOP•3mo ago
it seems the rendering is wrong but when submitting instantly I get the expected values 🤔 Maybe <div>{JSON.stringify(form.state.values)}</div> just doesn't work? Because this works 🙂
<div>
{Object.entries(form.state.values).map(([fieldID, value]) => (
<div key={fieldID}>
{fieldID} - {Array.isArray(value) ? value.join(", ") : String(value)}
</div>
))}
</div>
<div>
{Object.entries(form.state.values).map(([fieldID, value]) => (
<div key={fieldID}>
{fieldID} - {Array.isArray(value) ? value.join(", ") : String(value)}
</div>
))}
</div>
multiple-amethyst
multiple-amethyst•3mo ago
oh, you should check the Reactivity section of Basic Concepts the form variable is stable, so if you want to listen to props you need a hook or the subscribe element

Did you find this page helpful?