Skip to content

Update App.js: React Router Dom new Version#51

Open
Sheharyark wants to merge 1 commit intoCleverProgrammers:masterfrom
Sheharyark:patch-1
Open

Update App.js: React Router Dom new Version#51
Sheharyark wants to merge 1 commit intoCleverProgrammers:masterfrom
Sheharyark:patch-1

Conversation

@Sheharyark
Copy link

Here,
#I changer the routes according to the new version of react router dom
in react-router-dom v6, "Switch" is replaced by routes "Routes". You need to update the import from
##import { Switch, Route } from "react-router-dom";

to

##import { Routes ,Route } from 'react-router-dom';
You also need to update the Route declaration from

##

to

##<Route path='/welcome' element={} />

In react-router-dom, you also do not need to use the exact in the Route declaration.

Here,
#I changer the routes according to the new version of react router dom
in react-router-dom v6, "Switch" is replaced by routes "Routes". You need to update the import from
import { Switch, Route } from "react-router-dom";
to

import { Routes ,Route } from 'react-router-dom';
You also need to update the Route declaration from

<Route path="/" component={Home} />
to

<Route path='/welcome' element={<Home/>} />
In react-router-dom, you also do not need to use the exact in the Route declaration.
@Sheharyark
Copy link
Author

#I changer the routes according to the new version of react router dom

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant