-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
patch react-navigation to fix history bug (#2955)
* patch react-navigation - react-navigation/react-navigation#11833 * add readme
- Loading branch information
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
diff --git a/node_modules/@react-navigation/native/lib/commonjs/useLinking.js b/node_modules/@react-navigation/native/lib/commonjs/useLinking.js | ||
index ef4f368..2b0da35 100644 | ||
--- a/node_modules/@react-navigation/native/lib/commonjs/useLinking.js | ||
+++ b/node_modules/@react-navigation/native/lib/commonjs/useLinking.js | ||
@@ -273,8 +273,12 @@ function useLinking(ref, _ref) { | ||
}); | ||
const currentIndex = history.index; | ||
try { | ||
- if (nextIndex !== -1 && nextIndex < currentIndex) { | ||
- // An existing entry for this path exists and it's less than current index, go back to that | ||
+ if ( | ||
+ nextIndex !== -1 && | ||
+ nextIndex < currentIndex && | ||
+ // We should only go back if the entry exists and it's less than current index | ||
+ history.get(nextIndex - currentIndex) | ||
+ ) { // An existing entry for this path exists and it's less than current index, go back to that | ||
await history.go(nextIndex - currentIndex); | ||
} else { | ||
// We couldn't find an existing entry to go back to, so we'll go back by the delta | ||
diff --git a/node_modules/@react-navigation/native/lib/module/useLinking.js b/node_modules/@react-navigation/native/lib/module/useLinking.js | ||
index 62a3b43..11a5a28 100644 | ||
--- a/node_modules/@react-navigation/native/lib/module/useLinking.js | ||
+++ b/node_modules/@react-navigation/native/lib/module/useLinking.js | ||
@@ -264,8 +264,12 @@ export default function useLinking(ref, _ref) { | ||
}); | ||
const currentIndex = history.index; | ||
try { | ||
- if (nextIndex !== -1 && nextIndex < currentIndex) { | ||
- // An existing entry for this path exists and it's less than current index, go back to that | ||
+ if ( | ||
+ nextIndex !== -1 && | ||
+ nextIndex < currentIndex && | ||
+ // We should only go back if the entry exists and it's less than current index | ||
+ history.get(nextIndex - currentIndex) | ||
+ ) { // An existing entry for this path exists and it's less than current index, go back to that | ||
await history.go(nextIndex - currentIndex); | ||
} else { | ||
// We couldn't find an existing entry to go back to, so we'll go back by the delta | ||
diff --git a/node_modules/@react-navigation/native/src/useLinking.tsx b/node_modules/@react-navigation/native/src/useLinking.tsx | ||
index 3db40b7..9ba4ecd 100644 | ||
--- a/node_modules/@react-navigation/native/src/useLinking.tsx | ||
+++ b/node_modules/@react-navigation/native/src/useLinking.tsx | ||
@@ -381,7 +381,12 @@ export default function useLinking( | ||
const currentIndex = history.index; | ||
|
||
try { | ||
- if (nextIndex !== -1 && nextIndex < currentIndex) { | ||
+ if ( | ||
+ nextIndex !== -1 && | ||
+ nextIndex < currentIndex && | ||
+ // We should only go back if the entry exists and it's less than current index | ||
+ history.get(nextIndex - currentIndex) | ||
+ ) { | ||
// An existing entry for this path exists and it's less than current index, go back to that | ||
await history.go(nextIndex - currentIndex); | ||
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# React Navigation history bug patch | ||
|
||
This patches react-navigation to fix the issues in https://github.com/bluesky-social/social-app/issues/710. | ||
|
||
This is based on the PR found at https://github.com/react-navigation/react-navigation/pull/11833 |