ErrorFallback.tsx 879 B

12345678910111213141516171819202122232425262728293031
  1. import styled from '@emotion/styled'
  2. import { FallbackRender } from '@sentry/react/dist/errorboundary'
  3. import React from 'react'
  4. import { Button, Text } from '@/shared/components'
  5. import { colors, sizes } from '@/shared/theme'
  6. import { Logger } from '@/utils/logger'
  7. const Container = styled.div`
  8. padding: ${sizes(4)};
  9. color: ${colors.gray[400]};
  10. display: grid;
  11. place-items: center;
  12. `
  13. const StyledButton = styled(Button)`
  14. color: ${colors.white};
  15. `
  16. type FallbackProps = Partial<Parameters<FallbackRender>[0]>
  17. export const ErrorFallback: React.FC<FallbackProps> = ({ error, componentStack, resetError }) => {
  18. Logger.error(`An error occurred in ${componentStack}`, error)
  19. return (
  20. <Container>
  21. <Text>Something went wrong...</Text>
  22. <StyledButton variant="tertiary" onClick={resetError}>
  23. Try again
  24. </StyledButton>
  25. </Container>
  26. )
  27. }