import { Suspense, lazy } from 'react'
import { ErrorBoundary } from 'react-error-boundary'

const LazyComponent = lazy(() => import('./MyComponent'))

function ErrorFallBack({error, resetErrorBoundary }) {
    return (
        <div>
            <h2>Что то сломалось</h2>
            <button onClick={resetErrorBoundary}></button>
        </div>
    )
}

function App() {
	return (
		<>
			<ErrorBoundary FallBackComponent={ErrorFallBack}>
                <Suspense fallback={<div>Загрузка ...</div>}>
			        <LazyComponent />
                </Suspense>
            </ErrorBoundary>
		</>
	)
}

export default App
