| 1 | /** |
| 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. |
| 3 | * |
| 4 | * This source code is licensed under the MIT license found in the |
| 5 | * LICENSE file in the root directory of this source tree. |
| 6 | */ |
| 7 | |
| 8 | import {ErrorBoundary} from 'isl-components/ErrorNotice'; |
| 9 | import {Icon} from 'isl-components/Icon'; |
| 10 | import {Suspense} from 'react'; |
| 11 | |
| 12 | /** |
| 13 | * <ErrorBoundary> and <Suspense>, with a default fallback. |
| 14 | */ |
| 15 | export function SuspenseBoundary(props: { |
| 16 | children: React.ReactNode; |
| 17 | fallback?: JSX.Element; |
| 18 | }): JSX.Element { |
| 19 | const fallback = props.fallback ?? <Icon icon="loading" />; |
| 20 | |
| 21 | return ( |
| 22 | <ErrorBoundary> |
| 23 | <Suspense fallback={fallback}>{props.children}</Suspense> |
| 24 | </ErrorBoundary> |
| 25 | ); |
| 26 | } |
| 27 | |