[fix] double spinner (#2963)

Fixes a double spinner in the loading component.

### Change Type

- [x] `patch` — Bug fix
This commit is contained in:
Steve Ruiz 2024-02-27 09:30:02 +00:00 committed by GitHub
parent 2a6576a2dc
commit d88ce929eb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -13,7 +13,6 @@ import React, {
import classNames from 'classnames' import classNames from 'classnames'
import { OptionalErrorBoundary } from './components/ErrorBoundary' import { OptionalErrorBoundary } from './components/ErrorBoundary'
import { DefaultErrorFallback } from './components/default-components/DefaultErrorFallback' import { DefaultErrorFallback } from './components/default-components/DefaultErrorFallback'
import { DefaultLoadingScreen } from './components/default-components/DefaultLoadingScreen'
import { TLUser, createTLUser } from './config/createTLUser' import { TLUser, createTLUser } from './config/createTLUser'
import { TLAnyShapeUtilConstructor } from './config/defaultShapes' import { TLAnyShapeUtilConstructor } from './config/defaultShapes'
import { Editor } from './editor/Editor' import { Editor } from './editor/Editor'
@ -229,6 +228,8 @@ const TldrawEditorWithLoadingStore = memo(function TldrawEditorBeforeLoading({
} }
}, [container, user]) }, [container, user])
const { LoadingScreen } = useEditorComponents()
switch (store.status) { switch (store.status) {
case 'error': { case 'error': {
// for error handling, we fall back to the default error boundary. // for error handling, we fall back to the default error boundary.
@ -237,8 +238,7 @@ const TldrawEditorWithLoadingStore = memo(function TldrawEditorBeforeLoading({
throw store.error throw store.error
} }
case 'loading': { case 'loading': {
const LoadingScreen = rest.components?.LoadingScreen ?? DefaultLoadingScreen return LoadingScreen ? <LoadingScreen /> : null
return <LoadingScreen />
} }
case 'not-synced': { case 'not-synced': {
break break
@ -368,14 +368,7 @@ function Crash({ crashingError }: { crashingError: unknown }): null {
/** @public */ /** @public */
export function LoadingScreen({ children }: { children: any }) { export function LoadingScreen({ children }: { children: any }) {
const { Spinner } = useEditorComponents() return <div className="tl-loading">{children}</div>
return (
<div className="tl-loading">
{Spinner ? <Spinner /> : null}
{children}
</div>
)
} }
/** @public */ /** @public */