Как отладить Lazy, Suspense откат в реакции 16.6.3 - PullRequest
0 голосов
/ 04 декабря 2018

Мне нужно отладить Lazy, запасной резерв в реакции 16.6.3

Требуется обновить интерфейс загрузки.

В поисках лучшего решения.

https://reactjs.org/blog/2018/10/23/react-v-16-6.html#reactlazy-code-splitting-with-suspense

1 Ответ

0 голосов
/ 04 декабря 2018
import React, {lazy, Suspense} from 'react';
const OtherComponent = lazy(() => import('./OtherComponent'));

function MyComponent() {
  return (
    <Suspense fallback={<Fallback />}>
      <OtherComponent />
    </Suspense>
  );
}

function Fallback() {
  // debug it here to your heart's content
  // same thing with "OtherComponent", debug it in component
  return <div>Loading...</div>;
}
...