Skip to content

Commit

Permalink
fix: move worker setup under useEffect
Browse files Browse the repository at this point in the history
  • Loading branch information
VikaCep committed Jan 7, 2025
1 parent 33dad64 commit 1bb4a91
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export const App = (props: AppRootProps<ProvisioningJsonData>) => {
const { meta } = props;

useEffect(() => {
if (process.env.NODE_ENV === 'development' && process.env.REACT_APP_MSW) {
setupWorker(...handlers).start();
}

return () => {
// we have a dependency on alerts to display our alerting correctly
// so we are invalidating the alerts list on the assumption the user might change their alerting options when they leave SM
Expand All @@ -29,10 +33,6 @@ export const App = (props: AppRootProps<ProvisioningJsonData>) => {
};
}, []);

if (process.env.NODE_ENV === 'development' && process.env.REACT_APP_MSW) {
setupWorker(...handlers).start();
}

return (
<QueryClientProvider client={queryClient}>
<MetaContextProvider meta={meta}>
Expand Down

0 comments on commit 1bb4a91

Please sign in to comment.