main.tsx 1.7 KB

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