Skip to content

Commit 1d1d3aa

Browse files
authored
fix: avoid startTransition in React Native (#178)
1 parent 65e3f59 commit 1d1d3aa

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/FlagProvider.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export interface IFlagProvider {
99
unleashClient?: UnleashClient;
1010
startClient?: boolean;
1111
stopClient?: boolean;
12+
startTransition?: (fn: () => void) => void;
1213
}
1314

1415
const offlineConfig: IConfig = {
@@ -23,14 +24,16 @@ const offlineConfig: IConfig = {
2324
// save startTransition as var to avoid webpack analysis (https://github.com/webpack/webpack/issues/14814)
2425
const _startTransition = 'startTransition';
2526
// fallback for React <18 which doesn't support startTransition
26-
const startTransition = React[_startTransition] || (fn => fn());
27+
// Fallback for React <18 and exclude startTransition if in React Native
28+
const defaultStartTransition = React[_startTransition] || (fn => fn());
2729

2830
const FlagProvider: FC<PropsWithChildren<IFlagProvider>> = ({
2931
config: customConfig,
3032
children,
3133
unleashClient,
3234
startClient = true,
3335
stopClient = true,
36+
startTransition = defaultStartTransition
3437
}) => {
3538
const config = customConfig || offlineConfig;
3639
const client = React.useRef<UnleashClient>(

0 commit comments

Comments
 (0)