Kostya Tresko
Kostya Tresko

Reputation: 854

'Switch' (imported as 'Switch') was not found in 'react-router' error

Such error occurred in my project while building

WARNING in ./node_modules/react-router-config/esm/react-router-config.js 41:38-44
export 'Switch' (imported as 'Switch') was not found in 'react-router'

Along with this runtime error

react_router__WEBPACK_IMPORTED_MODULE_2__.Router.computeRootMatch is not a function

package.json

 "react-router-config": "^5.1.1",
 "react-router-dom": "5.2.0",
 "react": "17.0.1",
 "react-dom": "17.0.1",

I have not installed any new packages and cannot figure out solution

Upvotes: 0

Views: 585

Answers (1)

DoneDeal0
DoneDeal0

Reputation: 6257

You certainly have installed React Router v6. Switch is only available in V5 and below. You need to use Routes now.

Upvotes: 1

Related Questions