V
V
Vladimir2021-02-02 23:59:38
React
Vladimir, 2021-02-02 23:59:38

Why is it impossible to write to input when setting value to input?

How to get rid of this sick effect? I set the default value of the input:

<input type="number" placeholder={'Укажите КПП вашей компании'} maxLength={15} name={'kpp'} value={data ? data.map(el => el.data.kpp) : ''}/>

And after that you can’t write to it, I remember using the document.querySelector() input to select and set the same default value, everything was the way, the value was entered and you could change it in the field, for the first time I see this to be honest.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alex4answ, 2021-02-03
@HistoryART

Read the basics of react
1. set a default value: defaultValue="your value"
2. in react one-way binding, when you set a value on input it is expected that it will be updated in state, and then on input

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question