main.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import {browserHistory, Router, RouterContext} from 'react-router';
  2. import {QueryClient, QueryClientProvider} from '@tanstack/react-query';
  3. import DemoHeader from 'sentry/components/demo/demoHeader';
  4. import ThemeAndStyleProvider from 'sentry/components/themeAndStyleProvider';
  5. import {routes} from 'sentry/routes';
  6. import ConfigStore from 'sentry/stores/configStore';
  7. import {PersistedStoreProvider} from 'sentry/stores/persistedStore';
  8. import {RouteContext} from 'sentry/views/routeContext';
  9. /**
  10. * Renders our compatability RouteContext.Provider. This will go away with
  11. * react-router v6.
  12. */
  13. function renderRouter(props: any) {
  14. return (
  15. <RouteContext.Provider value={props}>
  16. <RouterContext {...props} />
  17. </RouteContext.Provider>
  18. );
  19. }
  20. const queryClient = new QueryClient();
  21. function Main() {
  22. return (
  23. <ThemeAndStyleProvider>
  24. <QueryClientProvider client={queryClient}>
  25. <PersistedStoreProvider>
  26. {ConfigStore.get('demoMode') && <DemoHeader />}
  27. <Router history={browserHistory} render={renderRouter}>
  28. {routes()}
  29. </Router>
  30. </PersistedStoreProvider>
  31. </QueryClientProvider>
  32. </ThemeAndStyleProvider>
  33. );
  34. }
  35. export default Main;