Styled components | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Styled components

Why input loose focus when i use onChange with styled components in react

28th Dec 2021, 6:21 AM
EsaKurniawan
1 Answer
0
This happens because you've defined Input within the render() method. Every time the state gets updated, the render() method will be called and Input will be redefined and handled as if it was a completely new component (a html <input/> without focus in this case). https://stackoverflow.com/questions/57096907/styled-component-input-loses-focus-onchange https://pretagteam.com/question/styled-component-input-loses-focus-onchange
3rd Jan 2022, 3:40 AM
NEZ
NEZ - avatar