Skip to content

Commit a503045

Browse files
committed
expose state transition on provided
1 parent 5213457 commit a503045

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/FlagProvider.tsx

Lines changed: 3 additions & 2 deletions
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,9 +24,8 @@ 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 isReactNative = typeof navigator !== 'undefined' && navigator?.product === 'ReactNative';
2727
// Fallback for React <18 and exclude startTransition if in React Native
28-
const startTransition: (fn: () => void) => void = !isReactNative && React[_startTransition]
28+
const defaultStartTransition: (fn: () => void) => void = React[_startTransition]
2929
? React[_startTransition]
3030
: (fn => fn());
3131

@@ -35,6 +35,7 @@ const FlagProvider: FC<PropsWithChildren<IFlagProvider>> = ({
3535
unleashClient,
3636
startClient = true,
3737
stopClient = true,
38+
startTransition = defaultStartTransition
3839
}) => {
3940
const config = customConfig || offlineConfig;
4041
const client = React.useRef<UnleashClient>(

0 commit comments

Comments
 (0)