withTeams.tsx 741 B

1234567891011121314151617181920212223242526272829
  1. import {Team} from 'sentry/types';
  2. import getDisplayName from 'sentry/utils/getDisplayName';
  3. import useTeams from 'sentry/utils/useTeams';
  4. type InjectedTeamsProps = {
  5. teams?: Team[];
  6. };
  7. /**
  8. * Higher order component that provides a list of teams
  9. *
  10. * @deprecated Prefer `useTeams` or `<Teams />`.
  11. */
  12. const withTeams = <P extends InjectedTeamsProps>(
  13. WrappedComponent: React.ComponentType<P>
  14. ) => {
  15. const WithTeams: React.FC<
  16. Omit<P, keyof InjectedTeamsProps> & InjectedTeamsProps
  17. > = props => {
  18. const {teams} = useTeams();
  19. return <WrappedComponent teams={teams} {...(props as P)} />;
  20. };
  21. WithTeams.displayName = `withTeams(${getDisplayName(WrappedComponent)})`;
  22. return WithTeams;
  23. };
  24. export default withTeams;