Skip to content

Commit 5213457

Browse files
committed
fix: avoid startTransition in React Native
1 parent 65e3f59 commit 5213457

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/FlagProvider.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ const offlineConfig: IConfig = {
2323
// save startTransition as var to avoid webpack analysis (https://github.com/webpack/webpack/issues/14814)
2424
const _startTransition = 'startTransition';
2525
// fallback for React <18 which doesn't support startTransition
26-
const startTransition = React[_startTransition] || (fn => fn());
26+
const isReactNative = typeof navigator !== 'undefined' && navigator?.product === 'ReactNative';
27+
// Fallback for React <18 and exclude startTransition if in React Native
28+
const startTransition: (fn: () => void) => void = !isReactNative && React[_startTransition]
29+
? React[_startTransition]
30+
: (fn => fn());
2731

2832
const FlagProvider: FC<PropsWithChildren<IFlagProvider>> = ({
2933
config: customConfig,

0 commit comments

Comments
 (0)