Export ‘Switch’ (Imported As ‘Switch’) Was Not Found In ‘React-Router-Dom’ With Example

Export ‘Switch’ (Imported As ‘Switch’) Was Not Found In ‘React-Router-Dom’ With Example

Hello guys, in this post, we will explain to you how to solve Export ‘Switch’ (Imported As ‘Switch’) Was Not Found In ‘React-Router-Dom’ With Example in react. we will give you a simple example of how to solve this error Export ‘Switch’ (Imported As ‘Switch’) Was Not Found In ‘React-Router-Dom’ With Example.

In react-router-dom v6, we need to change import Routes instead of Switch and instead of passing children prop to the Route components, we use the element prop. so you can follow the below example of react-router-dom v6.

If you are using react-router-dom v6, you must replace Switch with Routes. so that you can follow an example using react-router-dom V6.

If you followed the example above and still face the same problem, you can uninstall react-router-dom version 6 and install the react-router-dom version 5.2.0. so you can follow the command below.

Please follow and like us: