Using the marquee component in the antd-mobile component library in React reports an error in strict mode

通过ceact-react-app搭建的React项目,在使用antd-mobile组件库中的Carousel(跑马灯)组件时,报如下错误:
Insert picture description here
Warning: A string ref, “slider”, has been found within a strict mode tree. String refs are a source of potential bugs and should be avoided. We recommend using useRef() or createRef() instead. Learn more about using refs safely here: https://fb.me/react-strict-mode-string-ref

Warning: A string ref, “frame”, has been found within a strict mode tree. String refs are a source of potential bugs and should be avoided. We recommend using useRef() or createRef() instead. Learn more about using refs safely here:
https://fb.me/react-strict-mode-string-ref

(The error does not affect the operation of the project and the effect of the marquee)

According to the prompt of the error message: a string ref, "slider", has been found in a strict pattern tree. Explain that the strict mode is used in React.

Then naturally I thought of Strict Mode in React .
Insert picture description here
According to the above information, find index.js in the project src directory and delete the <React.StrictMode> tag. As shown in the figure below: the
Insert picture description here
error can be solved perfectly. ؏؏☝ᖗ乛◡乛ᖘ☝؏؏

Guess you like

Origin blog.csdn.net/it_cgq/article/details/106931152