Skip to content

Commit

Permalink
fix(react-bindings): multiple client async start handling while loading
Browse files Browse the repository at this point in the history
  • Loading branch information
nadavshatz committed Dec 19, 2024
1 parent e674819 commit 4f05bcb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export function useStatsigInternalClientFactoryAsync<T extends StatsigClient>(

const client = useMemo(() => {
if (clientRef.current) {
Promise.resolve(clientRef.current)
.catch(Log.error)
.finally(() => setIsLoading(false));

return clientRef.current;
}

Expand Down
8 changes: 6 additions & 2 deletions samples/react/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import '@fontsource/roboto/400.css';
import '@fontsource/roboto/500.css';
import '@fontsource/roboto/700.css';
import { Box } from '@mui/material';
import { ReactNode, lazy } from 'react';
import { ReactNode, StrictMode, lazy } from 'react';
import * as ReactDOM from 'react-dom/client';
import {
RouteObject,
Expand Down Expand Up @@ -89,4 +89,8 @@ function App() {
);
}

root.render(<App />);
root.render(
<StrictMode>
<App />
</StrictMode>,
);

0 comments on commit 4f05bcb

Please sign in to comment.