You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
305
+
Ionic React requires React Router v6. Install the following specific versions of the router packages to set up routing with Ionic React.
@@ -259,7 +245,7 @@ Once that is done, update the button in `Home.tsx`:
259
245
```
260
246
261
247
:::info
262
-
Navigating can also be performed programmatically using React Router's `history` prop. See the [React Navigation documentation](/docs/react/navigation.md#navigating-using-history) for more information.
248
+
Navigating can also be performed programmatically using the `useIonRouter` hook. See the [React Navigation documentation](/docs/react/navigation.md#useionrouter) for more information.
The `RouteComponentProps` type and its `history`, `location`, and `match` props are no longer available in React Router v6. Use the equivalent hooks instead:
119
+
120
+
-`history` -> `useNavigate` (see below) or `useIonRouter`
121
+
-`match.params` -> `useParams` (covered above)
122
+
-`location` -> `useLocation`
123
+
124
+
```diff
125
+
- import { RouteComponentProps } from 'react-router-dom';
126
+
+ import { useNavigate, useLocation } from 'react-router-dom';
The `useHistory` hook has been replaced with `useNavigate`:
166
+
167
+
```diff
168
+
- import { useHistory } from 'react-router-dom';
169
+
+ import { useNavigate } from 'react-router-dom';
170
+
+ import { useIonRouter } from '@ionic/react';
171
+
172
+
- const history = useHistory();
173
+
+ const navigate = useNavigate();
174
+
+ const router = useIonRouter();
175
+
176
+
- history.push('/path');
177
+
+ navigate('/path');
178
+
179
+
- history.replace('/path');
180
+
+ navigate('/path', { replace: true });
181
+
182
+
- history.goBack();
183
+
+ router.goBack();
184
+
```
185
+
186
+
#### Custom History Prop Removed
187
+
188
+
The `history` prop has been removed from `IonReactRouter`, `IonReactHashRouter`, and `IonReactMemoryRouter`. React Router v6 routers no longer accept custom `history` objects.
189
+
190
+
```diff
191
+
- import { createBrowserHistory } from 'history';
192
+
- const history = createBrowserHistory();
193
+
- <IonReactRouter history={history}>
194
+
+ <IonReactRouter>
195
+
```
196
+
197
+
For `IonReactMemoryRouter` (commonly used in tests), use `initialEntries` instead:
198
+
199
+
```diff
200
+
- import { createMemoryHistory } from 'history';
201
+
- const history = createMemoryHistory({ initialEntries: ['/start'] });
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:
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).
238
+
47
239
### Vue
48
240
49
241
1. Ionic 9 supports Vue 3.0.6+. Update to the latest version of Vue:
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.
264
+
265
+
If you need help upgrading, please post a thread on the [Ionic Forum](https://forum.ionicframework.com/).
0 commit comments