Browse Source

ref(js): Convert AlertsContainer to a FC (#30624)

Evan Purkhiser 3 years ago
parent
commit
2e8d96ca1a
1 changed files with 14 additions and 20 deletions
  1. 14 20
      static/app/views/alerts/index.tsx

+ 14 - 20
static/app/views/alerts/index.tsx

@@ -1,31 +1,25 @@
-import {cloneElement, Component, Fragment, isValidElement} from 'react';
+import {cloneElement, Fragment, isValidElement} from 'react';
 
-import Feature from 'sentry/components/acl/feature';
 import {Organization} from 'sentry/types';
 import withOrganization from 'sentry/utils/withOrganization';
 
 type Props = {
   organization: Organization;
+  children: React.ReactNode;
 };
 
-class AlertsContainer extends Component<Props> {
-  render() {
-    const {children, organization} = this.props;
-    return (
-      <Feature organization={organization} features={['incidents']}>
-        {({hasFeature: hasMetricAlerts}) => (
-          <Fragment>
-            {children && isValidElement(children)
-              ? cloneElement(children, {
-                  organization,
-                  hasMetricAlerts,
-                })
-              : children}
-          </Fragment>
-        )}
-      </Feature>
-    );
-  }
+function AlertsContainer({organization, children}: Props) {
+  const hasMetricAlerts = organization.features.includes('incidents');
+
+  const content =
+    children && isValidElement(children)
+      ? cloneElement(children, {
+          organization,
+          hasMetricAlerts,
+        })
+      : children;
+
+  return <Fragment>{content}</Fragment>;
 }
 
 export default withOrganization(AlertsContainer);