I am newbie in React.js and trying to use BackTop component in Ant Design library. https://ant.design/components/back-top/
This component works fine. But I found a error message in chrome browser console.
index.js:1 Warning: findDOMNode is deprecated in StrictMode. findDOMNode was passed an instance of DomWrapper which is inside StrictMode. Instead, add a ref directly to the element you want to reference. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-find-node
This is my code below.
Index.js
import React from 'react';
import ReactDOM from 'react-dom';
import 'antd/dist/antd.css';
import './assets/scss/global.scss';
import App from './App';
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
);
App.js
import React from "react";
import { Route, Switch, BrowserRouter as Router } from "react-router-dom";
import Header from './layouts/Header';
import Home from "./pages/Home";
import About from "./pages/About";
import { BackTop } from 'antd';
class App extends React.Component{
render(){
return (
<Router>
<Header/>
<div className="container">
<div className="content">
<Switch>
<Route exact path="/" component={Home} />
<Route path="/about" component={About} />
</Switch>
</div>
</div>
<BackTop />
</Router>
)
}
}
export default App;
What do I need to change to fix the error ?
findDOMNodehas been deprecated. You should not use it. It seems like some library is still usingfindDOMNode. So, you should just ignore this as it will be fixed when the library authors update the code. See this - Ajeet Shah