Skip to content

Commit

Permalink
Feat: 개발모드인 경우, msw를 init한 후 렌더링
Browse files Browse the repository at this point in the history
  • Loading branch information
navyjeongs committed Oct 30, 2023
1 parent f5d5ca0 commit 59f9207
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/components/MSWComponent/MSWComponent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import initMockAPI from '@mocks/index';
import { useEffect, useState } from 'react';

interface Props {
children: React.ReactNode;
}

const MSWComponent = ({ children }: Props) => {
const [mswStateIsReady, setMswStateIsReady] = useState<boolean>(false);

useEffect(() => {
const initMSW = async () => {
await initMockAPI();
setMswStateIsReady(true);
};

if (!mswStateIsReady) {
initMSW();
}
}, []);

if (!mswStateIsReady) {
return <>MSW Loading....</>;
}

return <>{children}</>;
};

export default MSWComponent;

0 comments on commit 59f9207

Please sign in to comment.