-
Notifications
You must be signed in to change notification settings - Fork 3.2k
docs(react-router): updating docs to reflect react router 6 changes #4422
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 all commits
2b442d1
8fcf1cf
bcf73fe
12981ad
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 |
|---|---|---|
|
|
@@ -300,23 +300,16 @@ Then, create `src/pages/Home.css`: | |
|
|
||
| #### 5. Set up Routing | ||
|
|
||
| :::important | ||
|
|
||
| Ionic React Router currently only supports React Router v5. You must install the following specific versions of the router packages to set up routing with Ionic React. | ||
|
|
||
| ::: | ||
|
|
||
| Install the router packages: | ||
|
|
||
| ```bash | ||
| npm install @ionic/react-router react-router@5 react-router-dom@5 | ||
| npm install @types/react-router-dom --save-dev | ||
| npm install @ionic/react-router react-router react-router-dom | ||
|
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. Why was the version removed? Shouldn't it be updated to v6 since we don't support v7? |
||
| ``` | ||
|
|
||
| Then, update `src/App.tsx` to add the routes for the Home page: | ||
|
|
||
| ```tsx title="src/App.tsx" | ||
| import { Redirect, Route } from 'react-router-dom'; | ||
| import { Route, Navigate } from 'react-router-dom'; | ||
| import { IonApp, IonRouterOutlet, setupIonicReact } from '@ionic/react'; | ||
| import { IonReactRouter } from '@ionic/react-router'; | ||
| import Home from './pages/Home'; | ||
|
|
@@ -329,12 +322,8 @@ const App: React.FC = () => ( | |
| <IonApp> | ||
| <IonReactRouter> | ||
| <IonRouterOutlet> | ||
| <Route exact path="/home"> | ||
| <Home /> | ||
| </Route> | ||
| <Route exact path="/"> | ||
| <Redirect to="/home" /> | ||
| </Route> | ||
| <Route path="/home" element={<Home />} /> | ||
| <Route path="/" element={<Navigate to="/home" replace />} /> | ||
| </IonRouterOutlet> | ||
| </IonReactRouter> | ||
| </IonApp> | ||
|
|
||
Large diffs are not rendered by default.
|
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. Adding this here so it has a thread: Don't we need to update the playgrounds as well or is that going to be done on a separate PR? See: ionic-docs/static/usage/v9/tabs/router/react/main_tsx.md Lines 19 to 30 in 1307564
|
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -44,6 +44,198 @@ npm install react@latest react-dom@latest | |||||||||||||||||||||||||||||||||||||||||||||||||
| npm install @ionic/react@latest @ionic/react-router@latest | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| 3. Update to React Router v6: | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| ```shell | ||||||||||||||||||||||||||||||||||||||||||||||||||
| npm install react-router@6 react-router-dom@6 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| If you have `@types/react-router` or `@types/react-router-dom` installed, remove them. React Router v6 includes its own TypeScript definitions: | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| ```shell | ||||||||||||||||||||||||||||||||||||||||||||||||||
| npm uninstall @types/react-router @types/react-router-dom | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+47
to
+57
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. I think we should put React Router in its own top-level section like React so it is easier to find and stands out more:
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| #### React Router v6 Migration | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
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.
Suggested change
Remove this header and just go into the steps to update |
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| Ionic React now requires React Router v6, which has a different API from v5. Below are the key changes you'll need to make: | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
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.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| **Route Definition Changes** | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
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.
Suggested change
Let's make these all headings so they can be linked to |
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| The `component` and `render` props have been replaced with the `element` prop, which accepts JSX: | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| ```diff | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - <Route path="/home" component={Home} exact /> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| + <Route path="/home" element={<Home />} /> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| Routes can no longer render content via nested children. All route content must be passed through the `element` prop: | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| ```diff | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - <Route path="/"> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - <Home /> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - </Route> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| + <Route path="/" element={<Home />} /> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| **Redirect Changes** | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
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.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| 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** | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
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.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| 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** | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
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.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| Route parameters are now accessed via the `useParams` hook instead of props: | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| ```diff | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - import { RouteComponentProps } from 'react-router-dom'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| + import { useParams } from 'react-router-dom'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| - const MyComponent: React.FC<RouteComponentProps<{ id: string }>> = ({ match }) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - const id = match.params.id; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| + const MyComponent: React.FC = () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| + const { id } = useParams<{ id: string }>(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| **RouteComponentProps Removed** | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
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.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| The `RouteComponentProps` type and its `history`, `location`, and `match` props are no longer available in React Router v6. Use the equivalent hooks instead: | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| - `history` -> `useNavigate` (see below) or `useIonRouter` | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - `match.params` -> `useParams` (covered above) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - `location` -> `useLocation` | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| ```diff | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - import { RouteComponentProps } from 'react-router-dom'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| + import { useNavigate, useLocation } from 'react-router-dom'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| + import { useIonRouter } from '@ionic/react'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| - const MyComponent: React.FC<RouteComponentProps> = ({ history, location }) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - history.push('/path'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - history.replace('/path'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - history.goBack(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - console.log(location.pathname); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| + const MyComponent: React.FC = () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| + const navigate = useNavigate(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| + const router = useIonRouter(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| + const location = useLocation(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| + // In an event handler or useEffect: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| + navigate('/path'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| + navigate('/path', { replace: true }); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| + router.goBack(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| + console.log(location.pathname); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| **Exact Prop Removed** | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
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.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| The `exact` prop is no longer needed. React Router v6 routes match exactly by default. To match sub-paths, use a `/*` suffix on the path: | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| ```diff | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - <Route path="/home" exact /> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| + <Route path="/home" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| **Render Prop Removed** | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
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.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| The `render` prop has been replaced with the `element` prop: | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| ```diff | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - <Route path="/foo" render={(props) => <Foo {...props} />} /> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| + <Route path="/foo" element={<Foo />} /> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| **Programmatic Navigation** | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
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.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| The `useHistory` hook has been replaced with `useNavigate`: | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| ```diff | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - import { useHistory } from 'react-router-dom'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| + import { useNavigate } from 'react-router-dom'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| + import { useIonRouter } from '@ionic/react'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| - const history = useHistory(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| + const navigate = useNavigate(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| + const router = useIonRouter(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| - history.push('/path'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| + navigate('/path'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| - history.replace('/path'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| + navigate('/path', { replace: true }); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| - history.goBack(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| + router.goBack(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| **Custom History Prop Removed** | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
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.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| The `history` prop has been removed from `IonReactRouter`, `IonReactHashRouter`, and `IonReactMemoryRouter`. React Router v6 routers no longer accept custom `history` objects. | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| ```diff | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - import { createBrowserHistory } from 'history'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - const history = createBrowserHistory(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - <IonReactRouter history={history}> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| + <IonReactRouter> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| For `IonReactMemoryRouter` (commonly used in tests), use `initialEntries` instead: | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| ```diff | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - import { createMemoryHistory } from 'history'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - const history = createMemoryHistory({ initialEntries: ['/start'] }); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - <IonReactMemoryRouter history={history}> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| + <IonReactMemoryRouter initialEntries={['/start']}> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| **IonRedirect Removed** | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
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.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| The `IonRedirect` component has been removed. Use React Router's `<Navigate>` component instead: | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| ```diff | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - import { IonRedirect } from '@ionic/react'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - <IonRedirect path="/old" to="/new" exact /> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| + import { Navigate } from 'react-router-dom'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| + <Route path="/old" element={<Navigate to="/new" replace />} /> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| **Path Regex Constraints Removed** | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
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.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| React Router v6 no longer supports regex constraints in path parameters (e.g., `/:tab(sessions)`). Use literal paths instead: | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| ```diff | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - <Route path="/:tab(sessions)" component={SessionsPage} /> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - <Route path="/:tab(sessions)/:id" component={SessionDetail} /> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| + <Route path="/sessions" element={<SessionsPage />} /> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| + <Route path="/sessions/:id" element={<SessionDetail />} /> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| **IonRoute API Changes** | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
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.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| The `IonRoute` component follows the same API changes as React Router's `<Route>`. The `render` prop has been replaced with `element`, and the `exact` prop has been removed: | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| ```diff | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - <IonRoute path="/foo" exact render={(props) => <Foo {...props} />} /> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| + <IonRoute path="/foo" element={<Foo />} /> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| For more information on migrating from React Router v5 to v6, refer to the [React Router v6 Upgrade Guide](https://reactrouter.com/6.28.0/upgrading/v5). | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| ### Vue | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| 1. Ionic 9 supports Vue 3.0.6+. Update to the latest version of Vue: | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -65,3 +257,9 @@ npm install @ionic/vue@latest @ionic/vue-router@latest | |||||||||||||||||||||||||||||||||||||||||||||||||
| ```shell | ||||||||||||||||||||||||||||||||||||||||||||||||||
| npm install @ionic/core@latest | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| ## Need Help Upgrading? | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| Be sure to look at the [Ionic 9 Breaking Changes Guide](https://github.com/ionic-team/ionic-framework/blob/main/BREAKING.md#version-9x) for the complete list of breaking changes. This upgrade guide only covers changes that require action from developers. | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| If you need help upgrading, please post a thread on the [Ionic Forum](https://forum.ionicframework.com/). | ||||||||||||||||||||||||||||||||||||||||||||||||||
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.
Why was this removed? Shouldn't it be updated to v6 since we don't support v7?