index.js:1 Warning: A string ref, “slider“, has been found within a strict mode tree. String refs ar

在这里插入图片描述

控制台报错

index.js:1 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://reactjs.org/link/strict-mode-string-ref

解决这是因为React的严格模式导致的.

React.StrictMode标签去掉即可,这是React的严格模式导致的。

import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import 'antd-mobile/dist/antd-mobile.css';
import './assets/fonts/iconfont.css'
import './index.css';

ReactDOM.render(
  // <React.StrictMode>
    <App />,
  // </React.StrictMode>,
  document.getElementById('root')
);

猜你喜欢

转载自blog.csdn.net/weixin_43131046/article/details/120565578