React function component renders twice

Rendering twice is because react has strict mode turned on by default.

React.StrictMode tag function:

1. Identifying unsafe lifecycles
2. Warning about using the outdated string ref API
3. About using the deprecated findDOMNode method Warning
4. Detect unexpected side effects
5. Detect obsolete context API

Commenting out React.StrictMode will turn off strict mode, and there will be no need to render twice.

Guess you like

Origin blog.csdn.net/qq_45600228/article/details/134538132