@ionic/react-router 9.0.11-nightly.20261110 → 9.0.11-nightly.20261111
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +24 -4
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useRef, useState, useEffect, useCallback } from 'react';
|
|
2
2
|
import { Route, matchPath as matchPath$1, Routes, Navigate, UNSAFE_RouteContext, matchRoutes, useLocation, useNavigate, BrowserRouter, useNavigationType, HashRouter } from 'react-router-dom';
|
|
3
|
-
import { IonRoute, ViewStacks, generateId, ViewLifeCycleManager,
|
|
3
|
+
import { IonRoute, ViewStacks, generateId, ViewLifeCycleManager, StackContext, createDebugLogger, RouteManagerContext, getConfig, LocationHistory, NavManager } from '@ionic/react';
|
|
4
4
|
import { LIFECYCLE_WILL_LEAVE, LIFECYCLE_DID_LEAVE, LIFECYCLE_WILL_ENTER, LIFECYCLE_DID_ENTER } from '@ionic/core/components';
|
|
5
5
|
import { MemoryRouter, useLocation as useLocation$1, useNavigationType as useNavigationType$1 } from 'react-router';
|
|
6
6
|
|
|
@@ -752,6 +752,19 @@ const ViewRouteContextProvider = ({ value, hold, children }) => {
|
|
|
752
752
|
}
|
|
753
753
|
return React.createElement(UNSAFE_RouteContext.Provider, { value: heldValue }, children);
|
|
754
754
|
};
|
|
755
|
+
/**
|
|
756
|
+
* Passes the view that rendered a page to `registerIonPage`. A page that mounts
|
|
757
|
+
* during a navigation registers with the previous pathname, so the path lookup
|
|
758
|
+
* alone can pick the wrong view.
|
|
759
|
+
*/
|
|
760
|
+
const ViewStackContextProvider = ({ viewItem, children }) => {
|
|
761
|
+
const parent = React.useContext(StackContext);
|
|
762
|
+
const value = React.useMemo(() => ({
|
|
763
|
+
...parent,
|
|
764
|
+
registerIonPage: (page, routeInfo) => parent.registerIonPage(page, routeInfo, viewItem),
|
|
765
|
+
}), [parent, viewItem]);
|
|
766
|
+
return React.createElement(StackContext.Provider, { value: value }, children);
|
|
767
|
+
};
|
|
755
768
|
class ReactRouterViewStack extends ViewStacks {
|
|
756
769
|
/**
|
|
757
770
|
* Stores the computed parent path for each outlet.
|
|
@@ -1053,7 +1066,8 @@ class ReactRouterViewStack extends ViewStacks {
|
|
|
1053
1066
|
? { ...parentContext, matches: contextMatches }
|
|
1054
1067
|
: { outlet: null, matches: contextMatches, isDataRoute: false };
|
|
1055
1068
|
return (React.createElement(ViewLifeCycleManager, { key: `view-${viewItem.id}`, mount: viewItem.mount, removeView: () => this.remove(viewItem) },
|
|
1056
|
-
React.createElement(ViewRouteContextProvider, { value: routeContextValue, hold: holdRouteContext },
|
|
1069
|
+
React.createElement(ViewRouteContextProvider, { value: routeContextValue, hold: holdRouteContext },
|
|
1070
|
+
React.createElement(ViewStackContextProvider, { viewItem: viewItem }, componentElement))));
|
|
1057
1071
|
}));
|
|
1058
1072
|
};
|
|
1059
1073
|
/**
|
|
@@ -2487,8 +2501,9 @@ class StackManager extends React.PureComponent {
|
|
|
2487
2501
|
*
|
|
2488
2502
|
* @param page The element of the rendered `<IonPage>`.
|
|
2489
2503
|
* @param routeInfo The route information that associates with `<IonPage>`.
|
|
2504
|
+
* @param ownerViewItem The view item that rendered `<IonPage>`, if known.
|
|
2490
2505
|
*/
|
|
2491
|
-
registerIonPage(page, routeInfo) {
|
|
2506
|
+
registerIonPage(page, routeInfo, ownerViewItem) {
|
|
2492
2507
|
/**
|
|
2493
2508
|
* DO NOT remove ion-page-invisible here.
|
|
2494
2509
|
*
|
|
@@ -2507,7 +2522,12 @@ class StackManager extends React.PureComponent {
|
|
|
2507
2522
|
this.ionPageWaitTimeout = undefined;
|
|
2508
2523
|
}
|
|
2509
2524
|
this.pendingPageTransition = false;
|
|
2510
|
-
const
|
|
2525
|
+
const pathView = this.context.findViewItemByRouteInfo(routeInfo, this.id);
|
|
2526
|
+
/**
|
|
2527
|
+
* The lookup can use a stale pathname (see `ViewStackContextProvider`), so
|
|
2528
|
+
* prefer the view that rendered the page when the two disagree.
|
|
2529
|
+
*/
|
|
2530
|
+
const foundView = pathView && ownerViewItem?.outletId === this.id && pathView !== ownerViewItem ? ownerViewItem : pathView;
|
|
2511
2531
|
if (foundView) {
|
|
2512
2532
|
const oldPageElement = foundView.ionPageElement;
|
|
2513
2533
|
/**
|