Repository navigation
fix(deps): update react-router monorepo to v6 (major) #3563
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
asajjad2
wants to merge
14
commits into
master
Choose a base branch
from
areeb/react-router-upgrade-v6
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
20fdfc4
fix(deps): update react-router monorepo to v6
asajjad2 ef52ab2
test: update register page tests for react-router-dom v7+ compatability
asajjad2 1991bd9
style: prettier errors
asajjad2 40d9fde
test: fix register page tests for react-router v7
asajjad2 7744dd5
refactor: replace withRouter in ScrollToTop with useLocation hook
asajjad2 e6e0d74
refactor: use BrowserRouter from react-router-dom in Router.js
asajjad2 c1e27e5
fix: import Route in Router.js
asajjad2 2a7ec5a
refactor: replace Switch with Routes
asajjad2 e87b2bb
refactor: replace Redirect with Navigate
asajjad2 5b6e911
test: update PrivateRoute test to expect Navigate instead of Redirect
asajjad2 f39f2a8
refactor: update Route component/render to element prop
asajjad2 b5d6f75
fix: wrap withTracker(App) in a component for Route element in Router.js
asajjad2 c5a305a
refactor: flatten forgotpassword routes, replace url with path
asajjad2 ed202b5
chore: ran yarn install
asajjad2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,30 +1,31 @@ | ||
| import React from "react" | ||
| import { Route, Router as ReactRouter } from "react-router" | ||
| import { BrowserRouter, Route } from "react-router-dom" | ||
| import { Provider } from "react-redux" | ||
|
|
||
| import App from "./containers/App" | ||
| import withTracker from "./util/withTracker" | ||
| import ScrollToTop from "./components/ScrollToTop" | ||
|
|
||
| const TrackedApp = withTracker(App); | ||
|
|
||
| export default class Root extends React.Component { | ||
| props: { | ||
| history: Object, | ||
| store: Store | ||
| } | ||
|
|
||
| render() { | ||
| const { children, history, store } = this.props | ||
| const { children, store } = this.props | ||
|
|
||
| return ( | ||
| <div> | ||
| <Provider store={store}> | ||
| <ReactRouter history={history}> | ||
| <BrowserRouter> | ||
| <ScrollToTop>{children}</ScrollToTop> | ||
| </ReactRouter> | ||
| </BrowserRouter> | ||
| </Provider> | ||
| </div> | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| export const routes = <Route url="/" component={withTracker(App)} /> | ||
| export const routes = <Route path="/" element={<TrackedApp />} /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,12 @@ | ||
| import React from "react"; | ||
| import { withRouter } from "react-router"; | ||
| import React, { useEffect } from "react"; | ||
| import { useLocation } from "react-router-dom"; | ||
|
|
||
| class ScrollToTop extends React.Component { | ||
| componentDidUpdate(prevProps) { | ||
| if (this.props.location.pathname !== prevProps.location.pathname) { | ||
| window.scrollTo(0, 0); | ||
| } | ||
| } | ||
|
|
||
| render() { | ||
| return this.props.children; | ||
| } | ||
| function ScrollToTop({ children }) { | ||
| const location = useLocation(); | ||
| useEffect(() => { | ||
| window.scrollTo(0, 0); | ||
| }, [location.pathname]); | ||
| return children; | ||
| } | ||
|
|
||
| export default withRouter(ScrollToTop); | ||
| export default ScrollToTop; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,7 @@ declare var USER_PERMISSIONS: { | |
| has_coupon_product_assignment_permission: boolean, | ||
| }; | ||
| import React from "react"; | ||
| import { Redirect, Route, Switch, Link } from "react-router-dom"; | ||
| import { Navigate, Route, Routes, Link } from "react-router-dom"; | ||
|
|
||
| import { routes } from "../../../lib/urls"; | ||
|
|
||
|
|
@@ -50,34 +50,34 @@ const EcommerceAdminIndexPage = () => ( | |
|
|
||
| const EcommerceAdminPages = () => ( | ||
| <React.Fragment> | ||
| <Switch> | ||
| <Routes> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| <Route | ||
| exact | ||
| path={routes.ecommerceAdmin.index} | ||
| component={EcommerceAdminIndexPage} | ||
| element={<EcommerceAdminIndexPage />} | ||
| /> | ||
| <Route | ||
| exact | ||
| path={routes.ecommerceAdmin.coupons} | ||
| component={CouponCreationPage} | ||
| path={routes.ecommerceAdmin.coupons.create} | ||
| element={<CouponCreationPage />} | ||
| /> | ||
| <Route | ||
| exact | ||
| path={routes.ecommerceAdmin.deactivate} | ||
| component={DeactivateCouponPage} | ||
| path={routes.ecommerceAdmin.coupons.deactivate} | ||
| element={<DeactivateCouponPage />} | ||
| /> | ||
| <Route | ||
| exact | ||
| path={routes.ecommerceAdmin.processSheets} | ||
| component={ProcessCouponAssignmentSheetPage} | ||
| path={routes.ecommerceAdmin.coupons.processAssignmentSheet} | ||
| element={<ProcessCouponAssignmentSheetPage />} | ||
| /> | ||
| <Route | ||
| exact | ||
| path={routes.ecommerceAdmin.updatePromoCode} | ||
| component={UpdatePromoCodePage} | ||
| path={routes.ecommerceAdmin.coupons.updatePromoCode} | ||
| element={<UpdatePromoCodePage />} | ||
| /> | ||
| <Redirect to={routes.ecommerceAdmin.index} /> | ||
| </Switch> | ||
| <Navigate to={routes.ecommerceAdmin.index} /> | ||
| </Routes> | ||
| </React.Fragment> | ||
| ); | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,17 @@ | ||
| // @flow | ||
| import React from "react"; | ||
| import { Switch, Route } from "react-router-dom"; | ||
| import { Routes, Route } from "react-router-dom"; | ||
|
|
||
| import { routes } from "../../../lib/urls"; | ||
|
|
||
| import ViewProfilePage from "./ViewProfilePage"; | ||
| import EditProfilePage from "./EditProfilePage"; | ||
|
|
||
| const ProfilePages = () => ( | ||
| <Switch> | ||
| <Route exact path={routes.profile.view} component={ViewProfilePage} /> | ||
| <Route exact path={routes.profile.edit} component={EditProfilePage} /> | ||
| </Switch> | ||
| <Routes> | ||
| <Route exact path={routes.profile.view} element={<ViewProfilePage />} /> | ||
| <Route exact path={routes.profile.edit} element={<EditProfilePage />} /> | ||
| </Routes> | ||
| ); | ||
|
|
||
| export default ProfilePages; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
<Switch>component has been replaced with<Routes>in React Router v6.