Skip to content

Commit

Permalink
simplify ErrorBoundary components
Browse files Browse the repository at this point in the history
  • Loading branch information
Jpoliachik committed Jan 25, 2024
1 parent d525912 commit 942a12b
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions docs/recipes/ExpoRouter.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ if (__DEV__) {
require("src/devtools/ReactotronConfig.ts");
}

export { ErrorBoundary } from "src/components/ErrorBoundary";
export { ErrorBoundary } from "src/components/ErrorBoundary/ErrorBoundary";

export default function Root() {
// Wait for stores to load and render our layout inside of it so we have access
Expand All @@ -252,23 +252,11 @@ export default function Root() {
}
```

Move `ErrorBoundary` out of `screens` and into `src/components`:
Move `ErrorBoundary` out of `screens/ErrorScreen` and into `src/components/ErrorBoundary`:

```terminal
mv src/screens/ErrorScreen/* src/components
```

And update imports in `ErrorDetails.tsx`

```ts
// error-line-start
import { Button, Icon, Screen, Text } from "../../components";
import { colors, spacing } from "../../theme";
// error-line-end
// success-line-start
import { Button, Icon, Screen, Text } from ".";
import { colors, spacing } from "../theme";
// success-line-end
mkdir src/components/ErrorBoundary
mv src/screens/ErrorScreen/* src/components/ErrorBoundary
```

For starters, this sets up our error boundary for the app and handles waiting on our stores to rehydrate. `<Slot />` comes from `expo-router`, you can think of it like the `children` prop in `React`. This component can be wrapped with others to help create a layout.
Expand Down

0 comments on commit 942a12b

Please sign in to comment.