1

I can't roll back to previous versions of React, how should I overcome this error?

import { Component } from 'react' ;

import { withRouter} from "react-router-dom";

class ScrollToTop extends Component {
    componentDidUpdate(prevProps) {
      if (this.props.location !== prevProps.location) {
        window.scrollTo(0, 0)
      }
    }
  
    render() {
      return this.props.children
    }
  }
  
  export default withRouter(ScrollToTop)
jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
  • 1
    React Router 6 has moved over to hooks and function-based components, if you need a HOC just _write one_. – jonrsharpe May 01 '22 at 18:58
  • RRDv6 removed the `withRouter` HOC, if you still need one you'll need to [create it yourself](https://stackoverflow.com/a/64566486/8690857) or convert to React function components to use the React hooks directly. Or create a [`ScrollToTop`](https://stackoverflow.com/a/65710997/8690857) component. – Drew Reese May 02 '22 at 16:22

0 Answers0