Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(mobile): Stabilize native stack option updates #4037

Mergedjuliusmarmingemerged 6 commits intomain fromrefs/pull/4037/headmerged by juliusmarminge View on GitHub

Showing 3 changed files with 102 additions and 3 deletions.

x
0 of 3 viewed, 3 left
100 additions and 3 deletionsapps/mobile/src/native/StackHeader.tsxModified
View file
@@ -11,6 +11,7 @@
useEffect,
useLayoutEffect,
useMemo,
+ useRef,
type ReactElement,
type ReactNode,
} from "react";
@@ -61,20 +62,116 @@
return normalized as NativeStackNavigationOptions;
​
+function optionsSignature(value: unknown, seen = new WeakSet<object>()): string {
+ if (value === null) return "null";
+ switch (typeof value) {
+ case "boolean":
+ case "number":
+ case "string":
+ return JSON.stringify(value);
+ case "undefined":
+ return "undefined";
+ case "function":
+ // Header factories are frequently recreated inline. Their source is
+ // stable across equivalent renders, while a reference comparison would
+ // make navigation.setOptions re-enter the navigator indefinitely.
+ return `function:${Function.prototype.toString.call(value)}`;
+ case "symbol":
+ return `symbol:${String(value)}`;