main.tsx 1.5 KB

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