-
Notifications
You must be signed in to change notification settings - Fork 13.4k
feat(react-router): upgrade to react router 6 #30831
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
base: major-9.0
Are you sure you want to change the base?
Changes from 90 commits
4262324
f0127bd
cccf290
af7710b
e364fea
6a42e69
4aad76a
fd6baac
e76c1e8
2436ba3
ca27ed6
37f76c7
a78f6b3
93202c0
0008059
0a0dcb6
331b394
205a705
7ff8994
c45c0f9
12c49f5
71fb8cb
c6f8dd4
366004e
5cccf0b
e6e17eb
2656e98
10bb889
7a20697
9d69a69
9c5f55a
49cbc46
a926134
a65886b
51933fe
43e546b
fca5e6c
80ae239
c8cefd5
b0c95d4
662fd70
210bc16
6f7631d
6f72bbf
0949a87
8fd53b2
0ceee27
a6131ba
8035c82
a9a1de2
e293cc0
99436a3
33fc844
28ca3a7
0d83b77
054220d
1ed61a9
8dddf77
5b735cd
881068e
6cae9ad
763621d
d51f95e
59f2dbf
96c96fc
383ec04
10c31ed
045b0a7
3073a24
584dcf2
b02c197
7fd0659
fc6e482
6575a92
fbed1e0
8fbd2d4
3912623
00798d4
82fd1ba
5a77916
397b6f7
71e55ad
418ac75
99dcb35
a23f555
a565a37
cb94f73
fedca46
b2a7105
7fc43b6
6762e5b
b196665
2ff49c4
c283319
6a61ecf
07104c2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,13 +4,76 @@ This is a comprehensive list of the breaking changes introduced in the major ver | |
|
|
||
| ## Versions | ||
|
|
||
| - [Version 9.x](#version-9x) | ||
| - [Version 8.x](#version-8x) | ||
| - [Version 7.x](./BREAKING_ARCHIVE/v7.md) | ||
| - [Version 6.x](./BREAKING_ARCHIVE/v6.md) | ||
| - [Version 5.x](./BREAKING_ARCHIVE/v5.md) | ||
| - [Version 4.x](./BREAKING_ARCHIVE/v4.md) | ||
| - [Legacy](https://github.com/ionic-team/ionic-v3/blob/master/CHANGELOG.md) | ||
|
|
||
| ## Version 9.x | ||
|
|
||
| - [Framework Specific](#version-9x-framework-specific) | ||
| - [React](#version-9x-react) | ||
|
|
||
| <h2 id="version-9x-framework-specific">Framework Specific</h2> | ||
|
|
||
| <h4 id="version-9x-react">React</h4> | ||
|
Member
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. Should this be React Router? |
||
|
|
||
| The `@ionic/react-router` package now requires React Router v6. React Router v5 is no longer supported. | ||
|
|
||
| **Minimum Version Requirements** | ||
| | Package | Supported Version | | ||
| | ---------------- | ----------------- | | ||
| | react-router | 6.0.0+ | | ||
| | react-router-dom | 6.0.0+ | | ||
|
|
||
| React Router v6 introduces several API changes that will require updates to your application's routing configuration: | ||
|
|
||
| **Route Definition Changes** | ||
|
|
||
| The `component` prop has been replaced with the `element` prop, which accepts JSX: | ||
|
|
||
| ```diff | ||
| - <Route path="/home" component={Home} exact /> | ||
| + <Route path="/home" element={<Home />} /> | ||
| ``` | ||
|
|
||
| **Redirect Changes** | ||
|
|
||
| The `<Redirect>` component has been replaced with `<Navigate>`: | ||
|
|
||
| ```diff | ||
| - import { Redirect } from 'react-router-dom'; | ||
| + import { Navigate } from 'react-router-dom'; | ||
|
|
||
| - <Redirect to="/home" /> | ||
| + <Navigate to="/home" replace /> | ||
| ``` | ||
|
|
||
| **Nested Route Paths** | ||
|
|
||
| Routes that contain nested routes or child `IonRouterOutlet` components need a `/*` suffix to match sub-paths: | ||
|
|
||
| ```diff | ||
| - <Route path="/tabs" element={<Tabs />} /> | ||
| + <Route path="/tabs/*" element={<Tabs />} /> | ||
| ``` | ||
|
|
||
| **Accessing Route Parameters** | ||
|
|
||
| Route parameters are now accessed via the `useParams` hook instead of props: | ||
|
|
||
| ```diff | ||
| - const MyComponent: React.FC<RouteComponentProps<{ id: string }>> = ({ match }) => { | ||
| - const id = match.params.id; | ||
| + const MyComponent: React.FC = () => { | ||
| + const { id } = useParams<{ id: string }>(); | ||
| ``` | ||
|
|
||
| For more information on migrating from React Router v5 to v6, refer to the [React Router v6 Upgrade Guide](https://reactrouter.com/en/main/upgrading/v5). | ||
|
|
||
| ## Version 8.x | ||
|
Member
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. Version 8 needs to be moved to its own file, see the |
||
|
|
||
| - [Browser and Platform Support](#version-8x-browser-platform-support) | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.