Refactored Analytics component to functional component (#4247)

This commit is contained in:
Chavda Bhavik
2022-10-08 19:17:24 +05:30
committed by GitHub
parent 0d6b3a9816
commit 2938c4e18c

View File

@@ -2,8 +2,8 @@
import * as React from "react";
import env from "~/env";
export default class Analytics extends React.Component {
componentDidMount() {
const Analytics: React.FC = ({ children }) => {
React.useEffect(() => {
if (!env.GOOGLE_ANALYTICS_ID) {
return;
}
@@ -33,9 +33,9 @@ export default class Analytics extends React.Component {
if (document.body) {
document.body.appendChild(script);
}
}
}, []);
render() {
return this.props.children || null;
}
}
return <>{children}</>;
};
export default Analytics;