main.tsx 1.8 KB

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