Answer the question
In order to leave comments, you need to log in
Can I pass in initial state useState props?
I pass props to the hook state as the initial state . As a result, my name is undefined . In this case, if you display itemChange.name in the console, then everything works fine.
const [name, setName] = useState(itemChange.name);
Can I generally set the initial state in this way?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question