Skip to content

Commit 8d2c0a5

Browse files
committed
:^)
1 parent f3019e9 commit 8d2c0a5

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

site/src/components/ErrorBoundary/ErrorBoundary.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
import { Component, ReactNode, PropsWithChildren } from "react";
1+
import { Component, type ReactNode } from "react";
22
import { RuntimeErrorState } from "./RuntimeErrorState";
33

4-
type ErrorBoundaryProps = PropsWithChildren<unknown>;
4+
interface ErrorBoundaryProps {
5+
fallback?: ReactNode;
6+
children: ReactNode;
7+
}
58

69
interface ErrorBoundaryState {
710
error: Error | null;
811
}
912

1013
/**
1114
* Our app's Error Boundary
12-
* Read more about React Error Boundaries: https://reactjs.org/docs/error-boundaries.html
15+
* Read more about React Error Boundaries: https://react.dev/reference/react/Component#catching-rendering-errors-with-an-error-boundary
1316
*/
1417
export class ErrorBoundary extends Component<
1518
ErrorBoundaryProps,
@@ -20,13 +23,15 @@ export class ErrorBoundary extends Component<
2023
this.state = { error: null };
2124
}
2225

23-
static getDerivedStateFromError(error: Error): { error: Error } {
26+
static getDerivedStateFromError(error: Error): ErrorBoundaryState {
2427
return { error };
2528
}
2629

2730
render(): ReactNode {
2831
if (this.state.error) {
29-
return <RuntimeErrorState error={this.state.error} />;
32+
return (
33+
this.props.fallback ?? <RuntimeErrorState error={this.state.error} />
34+
);
3035
}
3136

3237
return this.props.children;

site/src/components/IconField/IconField.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import { css, Global, useTheme } from "@emotion/react";
22
import Button from "@mui/material/Button";
33
import InputAdornment from "@mui/material/InputAdornment";
44
import TextField, { type TextFieldProps } from "@mui/material/TextField";
5+
import { visuallyHidden } from "@mui/utils";
56
import { type FC, lazy, Suspense } from "react";
7+
import { ErrorBoundary } from "components/ErrorBoundary/ErrorBoundary";
68
import { Loader } from "components/Loader/Loader";
79
import { DropdownArrow } from "components/DropdownArrow/DropdownArrow";
810
import { Stack } from "components/Stack/Stack";
@@ -11,7 +13,6 @@ import {
1113
PopoverContent,
1214
PopoverTrigger,
1315
} from "components/Popover/Popover";
14-
import { visuallyHidden } from "@mui/utils";
1516

1617
// See: https://github.com/missive/emoji-mart/issues/51#issuecomment-287353222
1718
const urlFromUnifiedCode = (unified: string) =>
@@ -118,9 +119,12 @@ export const IconField: FC<IconFieldProps> = ({
118119
so we just have to sneak it into the DOM, which is kind of annoying, but means
119120
that users shouldn't ever spend time waiting for it to load. */}
120121
<div css={{ ...visuallyHidden }}>
121-
<Suspense>
122-
<EmojiPicker onEmojiSelect={() => {}} />
123-
</Suspense>
122+
{/* `ErrorBoundary` is for tests, this component requires `IntersectionObserver` */}
123+
<ErrorBoundary fallback={null}>
124+
<Suspense>
125+
<EmojiPicker onEmojiSelect={() => {}} />
126+
</Suspense>
127+
</ErrorBoundary>
124128
</div>
125129
</Stack>
126130
);

0 commit comments

Comments
 (0)