React.js - input losing focus when rerendering

后端 未结 19 2060
猫巷女王i
猫巷女王i 2020-12-05 01:49

I am just writing to text input and in onChange event i call setState, so React rerenders my UI. The problem is that the text input always lose a f

19条回答
  •  盖世英雄少女心
    2020-12-05 02:01

    Turns out I was binding this to the component which was causing it to rerender.

    I figured I'd post it here in case anyone else had this issue.

    I had to change

    
    

    To

    
    

    Simple fix since in my case, I didn't actually need this in renderField, but hopefully me posting this will help someone else.

提交回复
热议问题