React slow with multiple controlled text inputs

后端 未结 8 1127
心在旅途
心在旅途 2021-02-18 13:08

I have a form with multiple text inputs. I have them all set up as controlled inputs. When typing, there is a lag of up to several seconds for the new text to display in the fie

8条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-18 13:44

    Seeing as this still gets responses, thought I'd update this and close it. Calling handleChange within onChange would cause the entire form to rerender on every change, thereby slowing it down. If you had a simple form you could just update onBlur instead or create individual input components so the rerender would be isolated to that one input. Personally, I use and would recommend using Formik for building forms as it abstracts this complexity for you.

提交回复
热议问题