import {Component} from 'react'; import OrganizationsStore from 'sentry/stores/organizationsStore'; import {OrganizationSummary} from 'sentry/types'; import getDisplayName from 'sentry/utils/getDisplayName'; type InjectedOrganizationsProps = { organizations: OrganizationSummary[]; organizationsLoading?: boolean; }; type State = { organizations: OrganizationSummary[]; }; function withOrganizations

( WrappedComponent: React.ComponentType

) { class WithOrganizations extends Component< Omit & Partial, State > { static displayName = `withOrganizations(${getDisplayName(WrappedComponent)})`; state: State = {organizations: OrganizationsStore.getAll()}; componentWillUnmount() { this.unsubscribe(); } unsubscribe = OrganizationsStore.listen( (organizations: OrganizationSummary[]) => this.setState({organizations}), undefined ); render() { const {organizationsLoading, organizations, ...props} = this.props as P; return ( ); } } return WithOrganizations; } export default withOrganizations;