Skip to content

Commit

Permalink
start msw in root layout
Browse files Browse the repository at this point in the history
  • Loading branch information
vonkanehoffen committed Oct 22, 2024
1 parent c590823 commit 797761a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 32 deletions.
25 changes: 16 additions & 9 deletions app/_layout.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
import { DarkTheme, DefaultTheme, ThemeProvider } from '@react-navigation/native';
import { useFonts } from 'expo-font';
import { Stack } from 'expo-router';
import * as SplashScreen from 'expo-splash-screen';
import { useEffect } from 'react';
import 'react-native-reanimated';
import {
DarkTheme,
DefaultTheme,
ThemeProvider,
} from "@react-navigation/native";
import { useFonts } from "expo-font";
import { Stack } from "expo-router";
import * as SplashScreen from "expo-splash-screen";
import { useEffect } from "react";
import "react-native-reanimated";
import { server } from "../mocks/server";

import { useColorScheme } from '@/hooks/useColorScheme';
import { useColorScheme } from "@/hooks/useColorScheme";

server.listen();

// Prevent the splash screen from auto-hiding before asset loading is complete.
SplashScreen.preventAutoHideAsync();

export default function RootLayout() {
const colorScheme = useColorScheme();
const [loaded] = useFonts({
SpaceMono: require('../assets/fonts/SpaceMono-Regular.ttf'),
SpaceMono: require("../assets/fonts/SpaceMono-Regular.ttf"),
});

useEffect(() => {
Expand All @@ -27,7 +34,7 @@ export default function RootLayout() {
}

return (
<ThemeProvider value={colorScheme === 'dark' ? DarkTheme : DefaultTheme}>
<ThemeProvider value={colorScheme === "dark" ? DarkTheme : DefaultTheme}>
<Stack>
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
<Stack.Screen name="+not-found" />
Expand Down
26 changes: 3 additions & 23 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,3 @@
import { registerRootComponent } from "expo";
import { ExpoRoot } from "expo-router";

export const App = () => {
const ctx = require.context("./app");

return <ExpoRoot context={ctx} />;
};

async function enableMocking() {
if (!__DEV__) {
return;
}

await import("./msw.polyfills");
const { server } = await import("./mocks/server");

server.listen();
}

enableMocking().then(() => {
registerRootComponent(App);
});
import "fast-text-encoding";
import "react-native-url-polyfill/auto";
import "expo-router/entry";

0 comments on commit 797761a

Please sign in to comment.