why isn't input's value not updating when using useState value in it?
guys i have a useState that doesn't have any values, it later gets set to an object after a fetch request to an api
But if i use this useState object's value for an input, the input value is always empty
const user = useUser()
anyone know why the input's value never changes when the useState changes?8 Replies
should be a function
and it should return the currently set value
yeah, I wouldn't type it this way
how is this different from the code?
aren't they both the same?
@Nisthar that was mainly as an answer to @l422y. Code seems fine except that you don't have 2-way binding (e.g. with v-model) or reacthing on an @input event
that's why the input component never changes the state
but doesn't the input need to update when the value changes even if it is one way binding?
using v-model works, but i don't know why :value doesn't work for this
One way binding implies that when A changes, then B changes too
But not the other way around
is it a typical HTML input?
No its a shadcn-vue input component.
It might be why its not working
Yes i was expecting the input changes when the state changes
you might want to look up how you pass initial values into that
(default via the
modelValue
prop if a simple v-model
is used)