0

I have been using the LinkContainer from the react-router-bootstrap react library for a while but currently it is throwing this error when I import it:

TypeError (0 , _reactRouterDom.withRouter) is not a function

I have my very simple react application in this codesandbox over here

Help me debug this please.

Charleskimani
  • 440
  • 7
  • 25
  • 1
    Beginning in v6 of react-router, `withRouter` was removed. See the [upgrade-guide](https://reactrouter.com/docs/en/v6/upgrading/v5) - *Along with the upgrade to v5.1, you should replace any usage of withRouter with hooks* – Brian Thompson Nov 11 '21 at 14:42
  • Okay if I get any trouble I'll ask for your help @Brian Thompson – Charleskimani Nov 11 '21 at 14:45

1 Answers1

1

You have to options, either you downgrade your version (to v5.3.0) of react-router-dom so method withRouter will be available again (used by react-router-bootstrap) or you dismiss react-router-bootstrap and use the useNavigate Hook:

const navigate = useNavigate();
...
<Nav.Link onClick={() => navigate('configuration')}>