I was recently working on a personal project using input and suddenly noticed that React and HTML onChange are different
In input, onChange is triggered when the user moves the mouse over it, but React is not
React features: Only basic tools are provided. You build the rest yourself, unlike Vue.
HTML onChange
- Arbitrary input in the input will not trigger the onChange event immediately
- When will it be triggered?
- Answer: Mouse away after
The React of onChange
It will trigger when you type React. If you are learning React, you will be surprised. This is not characteristic of React!!
- Any input in the input will immediately trigger the onChange event
Note:
In index.tsx, you need to remove the React.StrictMode tag, otherwise there will be a bug that triggers onChange events twice
So maybe this is a hole in React