Просмотр исходного кода

ref(js): Remove componentPromise from Route props (#35038)

Evan Purkhiser 2 лет назад
Родитель
Сommit
0c81304186
4 измененных файлов с 259 добавлено и 345 удалено
  1. 1 1
      static/app/bootstrap/initializeApp.tsx
  2. 5 25
      static/app/components/lazyLoad.tsx
  3. 1 1
      static/app/main.tsx
  4. 252 318
      static/app/routes.tsx

+ 1 - 1
static/app/bootstrap/initializeApp.tsx

@@ -1,7 +1,7 @@
 import './legacyTwitterBootstrap';
 import './exportGlobals';
 
-import routes from 'sentry/routes';
+import {routes} from 'sentry/routes';
 import {Config} from 'sentry/types';
 import {metric} from 'sentry/utils/analytics';
 

+ 5 - 25
static/app/components/lazyLoad.tsx

@@ -16,40 +16,20 @@ type Props<C extends ComponentType> = Omit<React.ComponentProps<C>, 'route'> & {
   /**
    * Accepts a function to trigger the import resolution of the component.
    */
-  component?: () => PromisedImport<C>;
-  /**
-   * Accepts a route object from react-router that has a `componentPromise` property
-   */
-  route?: {componentPromise: () => PromisedImport<C>};
+  component: () => PromisedImport<C>;
 };
 
 /**
  * LazyLoad is used to dynamically load codesplit components via a `import`
- * call. Typically this component is used as part of the routing tree, though
- * it does have a standalone mode.
- *
- * Route tree usage:
- *   <Route
- *     path="somePath"
- *     component={LazyLoad}
- *     componentPromise={() => import('./somePathView')}
- *   />
+ * call. This is primarily used in our routing tree.
  *
- * Standalone usage:
- *   <LazyLoad component={() => import('./myComponent')} someComponentProps={...} />
+ * <LazyLoad component={() => import('./myComponent')} someComponentProps={...} />
  */
 function LazyLoad<C extends ComponentType>(props: Props<C>) {
-  const importComponent = props.component ?? props.route?.componentPromise;
+  const importComponent = props.component;
 
   const LazyComponent = useMemo(
-    () =>
-      lazy(() => {
-        if (!importComponent) {
-          throw new Error('No component to load');
-        }
-
-        return retryableImport(importComponent);
-      }),
+    () => lazy(() => retryableImport(importComponent)),
     [importComponent]
   );
 

+ 1 - 1
static/app/main.tsx

@@ -2,7 +2,7 @@ import {browserHistory, Router, RouterContext} from 'react-router';
 
 import DemoHeader from 'sentry/components/demo/demoHeader';
 import ThemeAndStyleProvider from 'sentry/components/themeAndStyleProvider';
-import routes from 'sentry/routes';
+import {routes} from 'sentry/routes';
 import ConfigStore from 'sentry/stores/configStore';
 import {RouteContext} from 'sentry/views/routeContext';
 

Разница между файлами не показана из-за своего большого размера
+ 252 - 318
static/app/routes.tsx


Некоторые файлы не были показаны из-за большого количества измененных файлов