addons/isl/src/SuspenseBoundary.tsxblame
View source
b69ab311/**
b69ab312 * Copyright (c) Meta Platforms, Inc. and affiliates.
b69ab313 *
b69ab314 * This source code is licensed under the MIT license found in the
b69ab315 * LICENSE file in the root directory of this source tree.
b69ab316 */
b69ab317
b69ab318import {ErrorBoundary} from 'isl-components/ErrorNotice';
b69ab319import {Icon} from 'isl-components/Icon';
b69ab3110import {Suspense} from 'react';
b69ab3111
b69ab3112/**
b69ab3113 * <ErrorBoundary> and <Suspense>, with a default fallback.
b69ab3114 */
b69ab3115export function SuspenseBoundary(props: {
b69ab3116 children: React.ReactNode;
b69ab3117 fallback?: JSX.Element;
b69ab3118}): JSX.Element {
b69ab3119 const fallback = props.fallback ?? <Icon icon="loading" />;
b69ab3120
b69ab3121 return (
b69ab3122 <ErrorBoundary>
b69ab3123 <Suspense fallback={fallback}>{props.children}</Suspense>
b69ab3124 </ErrorBoundary>
b69ab3125 );
b69ab3126}