Answer the question
In order to leave comments, you need to log in
Why does Redux only store one character?
Hello! I have a form:
<form onSubmit={register}>
<input
name="name"
component="input"
type="text"
placeholder="Имя и фамилия"
onChange={setName}
/>
</form>
export function setName(name) {
return {
type: 'SET_NAME',
payload: name,
}
}
Answer the question
In order to leave comments, you need to log in
When you read this article carefully, you should understand everything Managed Components
Now you are doing the following: an action is hung on the onChange event, as soon as you enter 1 character into the input, the action fires and changes the state in Redux. Redux updates the state and re-renders your component, and you re-type a character and again update your state in redux with that one character.
UPD: no, Redux won't render for you, because you are not using the entered value in any way. In general, read the article and see
the
sandbox
example .
But try to understand, and not stupidly copy, this is very important
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question