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

ref(js): Use stable Router `render` function (#39191)

Evan Purkhiser 2 лет назад
Родитель
Сommit
aea39b2f56
1 измененных файлов с 13 добавлено и 8 удалено
  1. 13 8
      static/app/main.tsx

+ 13 - 8
static/app/main.tsx

@@ -8,19 +8,24 @@ import {RouteContext} from 'sentry/views/routeContext';
 
 import {PersistedStoreProvider} from './stores/persistedStore';
 
+/**
+ * Renders our compatability RouteContext.Provider. This will go away with
+ * react-router v6.
+ */
+function renderRouter(props: any) {
+  return (
+    <RouteContext.Provider value={props}>
+      <RouterContext {...props} />
+    </RouteContext.Provider>
+  );
+}
+
 function Main() {
   return (
     <ThemeAndStyleProvider>
       <PersistedStoreProvider>
         {ConfigStore.get('demoMode') && <DemoHeader />}
-        <Router
-          history={browserHistory}
-          render={props => (
-            <RouteContext.Provider value={props}>
-              <RouterContext {...props} />
-            </RouteContext.Provider>
-          )}
-        >
+        <Router history={browserHistory} render={renderRouter}>
           {routes()}
         </Router>
       </PersistedStoreProvider>