Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 25 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@
"@react-native-firebase/app": "^22.2.1",
"@react-native-google-signin/google-signin": "^10.0.1",
"@react-native-picker/picker": "2.11.3",
"@react-navigation/bottom-tabs": "7.15.5",
"@react-navigation/bottom-tabs": "7.18.16",
"@react-navigation/core": "7.21.12",
"@react-navigation/material-top-tabs": "7.4.19",
"@react-navigation/native": "7.1.33",
"@react-navigation/native": "7.3.16",
"@react-navigation/native-stack": "7.14.5",
"@react-navigation/stack": "7.8.5",
"@react-ng/bounds-observer": "^0.2.1",
Expand Down Expand Up @@ -418,6 +418,7 @@
"node-abi": "^3.78.0",
"pdfjs-dist": "^5.5.207",
"lightningcss": "1.30.1",
"@react-navigation/elements": "2.9.38",
"@fullstory/react-native": {
"expo": "57.0.8"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,64 +1,45 @@
diff --git a/node_modules/@react-navigation/native/lib/module/createMemoryHistory.js b/node_modules/@react-navigation/native/lib/module/createMemoryHistory.js
index 474db5e..4d94ed8 100644
index 58a543b..c475462 100644
--- a/node_modules/@react-navigation/native/lib/module/createMemoryHistory.js
+++ b/node_modules/@react-navigation/native/lib/module/createMemoryHistory.js
@@ -1,10 +1,27 @@
@@ -1,6 +1,7 @@
"use strict";

import { nanoid } from 'nanoid/non-secure';
+import { findFocusedRouteKey } from "./findFocusedRouteKey.js";
const getPathWithoutHash = path => path.split('#')[0] ?? '';
export function createMemoryHistory() {
let index = 0;
let items = [];

+ // const log = () => {
+ // console.log(JSON.stringify({
+ // index,
+ // indexGetter: history.index,
+ // items: items.map((item, i) => {
+ // var _item$state;
+ // return {
+ // selected: history.index === i ? '<<<<<<<' : undefined,
+ // path: item.path,
+ // id: item.id,
+ // state: ((_item$state = item.state) === null || _item$state === void 0 ? void 0 : _item$state.key) || null
+ // };
+ // })
+ // }, null, 4));
+ // };
+
// Pending callbacks for `history.go(n)`
// We might modify the callback stored if it was interrupted, so we have a ref to identify it
const pending = [];
@@ -17,7 +34,10 @@ export function createMemoryHistory() {
it.cb = () => cb(true);
@@ -19,6 +20,9 @@ export function createMemoryHistory() {
});
};
- const history = {
+ return {
const history = {
+ get items() {
+ return items;
+ },
get index() {
// We store an id in the state instead of an index
// Index could get out of sync with in-memory values if page reloads
@@ -32,12 +52,13 @@ export function createMemoryHistory() {
@@ -33,7 +37,8 @@ export function createMemoryHistory() {
return items[index];
},
backIndex({
- path
+ path,
+ state
}) {
// We need to find the index from the element before current to get closest path to go back to
for (let i = index - 1; i >= 0; i--) {
const item = items[i];
- if (item.path === path) {
+ if (item.path === path && findFocusedRouteKey(item.state) === findFocusedRouteKey(state)) {
const pathWithoutHash = getPathWithoutHash(path);

@@ -43,7 +48,7 @@ export function createMemoryHistory() {
if (item == null) {
continue;
}
- if (item.path === pathWithoutHash) {
+ if (item.path === pathWithoutHash && findFocusedRouteKey(item.state) === findFocusedRouteKey(state)) {
return i;
}
}
@@ -77,7 +98,7 @@ export function createMemoryHistory() {
@@ -85,7 +90,7 @@ export function createMemoryHistory() {

// Need to keep the hash part of the path if there was no previous history entry
// or the previous history entry had the same path
Expand All @@ -67,40 +48,33 @@ index 474db5e..4d94ed8 100644
const hash = pathWithHash.includes('#') ? '' : location.hash;
if (!items.length || items.findIndex(item => item.id === id) < 0) {
// There are two scenarios for creating an array with only one history record:
@@ -211,6 +232,5 @@ export function createMemoryHistory() {
return () => window.removeEventListener('popstate', onPopState);
}
};
- return history;
}
//# sourceMappingURL=createMemoryHistory.js.map
diff --git a/node_modules/@react-navigation/native/lib/module/findFocusedRouteKey.js b/node_modules/@react-navigation/native/lib/module/findFocusedRouteKey.js
new file mode 100644
index 0000000..b996822
index 0000000..290e96f
--- /dev/null
+++ b/node_modules/@react-navigation/native/lib/module/findFocusedRouteKey.js
@@ -0,0 +1,8 @@
+"use strict";
+
+import { findFocusedRoute } from '@react-navigation/core';
+export function findFocusedRouteKey(state) {
+ const focusedRoute = findFocusedRoute(state);
+ return focusedRoute?.key;
+ const focusedRoute = findFocusedRoute(state);
+ return focusedRoute?.key;
+}
+//# sourceMappingURL=findFocusedRouteKey.js.map
diff --git a/node_modules/@react-navigation/native/lib/module/useLinking.js b/node_modules/@react-navigation/native/lib/module/useLinking.js
index d30009f..0dab822 100644
index 66b73b5..99b630d 100644
--- a/node_modules/@react-navigation/native/lib/module/useLinking.js
+++ b/node_modules/@react-navigation/native/lib/module/useLinking.js
@@ -4,6 +4,7 @@ import { findFocusedRoute, getActionFromState as getActionFromStateDefault, getP
@@ -4,6 +4,7 @@ import { CommonActions, findFocusedRoute, getActionFromState as getActionFromSta
import isEqual from 'fast-deep-equal';
import * as React from 'react';
import { createMemoryHistory } from "./createMemoryHistory.js";
+import { findFocusedRouteKey } from "./findFocusedRouteKey.js";
import { ServerContext } from "./ServerContext.js";

/**
* Find the matching navigation state that changed between 2 navigation states
@@ -45,6 +46,43 @@ export const series = cb => {
@@ -114,6 +115,43 @@ export const series = cb => {
return callback;
};
const linkingHandlers = [];
Expand Down Expand Up @@ -144,17 +118,17 @@ index d30009f..0dab822 100644
export function useLinking(ref, {
enabled = true,
config,
@@ -256,6 +294,9 @@ export function useLinking(ref, {
// Otherwise it's likely a change triggered by `popstate`
path !== pendingPath) {
const historyDelta = (focusedState.history ? focusedState.history.length : focusedState.routes.length) - (previousFocusedState.history ? previousFocusedState.history.length : previousFocusedState.routes.length);
@@ -409,6 +447,9 @@ export function useLinking(ref, {
const historyDelta = getHistoryLength(focusedState) - getHistoryLength(previousFocusedState) - (
// Subtract the delta already applied by the browser to sync only the remaining changes
pendingPopStateDelta ?? 0);
+
+ // The historyDelta and historyDeltaByKeys may differ if the new state has an entry that didn't exist in previous state
+ const historyDeltaByKeys = getHistoryDeltaByKeys(focusedState, previousFocusedState);
+ const historyDeltaByKeys = getHistoryDeltaByKeys(focusedState, previousFocusedState) - (pendingPopStateDelta ?? 0);
if (historyDelta > 0) {
// If history length is increased, we should pushState
// Note that path might not actually change here, for example, drawer open should pushState
@@ -267,7 +308,8 @@ export function useLinking(ref, {
@@ -420,7 +461,8 @@ export function useLinking(ref, {
// If history length is decreased, i.e. entries were removed, we want to go back

const nextIndex = history.backIndex({
Expand All @@ -164,7 +138,7 @@ index d30009f..0dab822 100644
});
const currentIndex = history.index;
try {
@@ -276,11 +318,26 @@ export function useLinking(ref, {
@@ -429,11 +471,26 @@ export function useLinking(ref, {
history.get(nextIndex)) {
// An existing entry for this path exists and it's less than current index, go back to that
await history.go(nextIndex - currentIndex);
Expand Down Expand Up @@ -192,7 +166,7 @@ index d30009f..0dab822 100644
}

// Store the updated state as well as fix the path if incorrect
@@ -293,10 +350,22 @@ export function useLinking(ref, {
@@ -446,10 +503,26 @@ export function useLinking(ref, {
}
} else {
// If history length is unchanged, we want to replaceState
Expand All @@ -210,11 +184,15 @@ index d30009f..0dab822 100644
+ state
+ });
+ } else {
+ await history.go(-staleHistoryDiff);
+ history.push({
+ path,
+ state
+ });
+ try {
+ await history.go(-staleHistoryDiff);
+ history.push({
+ path,
+ state
+ });
+ } catch (e) {
+ // The navigation was interrupted
+ }
+ }
}
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
diff --git a/node_modules/@react-navigation/native/lib/module/createMemoryHistory.js b/node_modules/@react-navigation/native/lib/module/createMemoryHistory.js
index c475462..f8e7d1c 100644
--- a/node_modules/@react-navigation/native/lib/module/createMemoryHistory.js
+++ b/node_modules/@react-navigation/native/lib/module/createMemoryHistory.js
@@ -189,10 +189,14 @@
@@ -188,10 +188,14 @@ export function createMemoryHistory() {
cb: done
});

Expand All @@ -17,8 +18,8 @@ diff --git a/node_modules/@react-navigation/native/lib/module/createMemoryHistor
+ // back/forward navigation and reset the app to a stale route
// We're using a hacky timeout since there doesn't seem to be way to know for sure
const timer = setTimeout(() => {
const foundIndex = pending.findIndex(it => it.ref === done);
@@ -201,7 +205,7 @@
window.removeEventListener('popstate', onPopState);
@@ -201,7 +205,7 @@ export function createMemoryHistory() {
pending.splice(foundIndex, 1);
}
index = this.index;
Expand Down
Loading
Loading