diff --git a/src/components/common/GoogleAnalytics.js b/src/components/common/GoogleAnalytics.tsx similarity index 59% rename from src/components/common/GoogleAnalytics.js rename to src/components/common/GoogleAnalytics.tsx index 4d0a3c0..5645da5 100644 --- a/src/components/common/GoogleAnalytics.js +++ b/src/components/common/GoogleAnalytics.tsx @@ -1,11 +1,16 @@ import React from 'react'; -import { withRouter } from 'react-router-dom'; +import { withRouter, RouteComponentProps } from 'react-router-dom'; import ReactGA from 'react-ga'; +type Props = {} & RouteComponentProps<{}>; + // Adapted from https://stackoverflow.com/a/47385875/5281021 -class GoogleAnalytics extends React.Component { - componentDidUpdate({ location, history }) { - ReactGA.initialize(process.env.REACT_APP_GA_TRACKING_ID, { +class GoogleAnalytics extends React.Component { + componentDidUpdate({ location, history }: Props) { + const { REACT_APP_GA_TRACKING_ID } = process.env; + if (!REACT_APP_GA_TRACKING_ID) return; + + ReactGA.initialize(REACT_APP_GA_TRACKING_ID, { debug: process.env.NODE_ENV === 'development', }); diff --git a/src/components/common/errors-loaders/Error.js b/src/components/common/errors-loaders/Error.tsx similarity index 57% rename from src/components/common/errors-loaders/Error.js rename to src/components/common/errors-loaders/Error.tsx index 9b51ccd..479a898 100644 --- a/src/components/common/errors-loaders/Error.js +++ b/src/components/common/errors-loaders/Error.tsx @@ -1,11 +1,18 @@ import React from 'react'; import styles from './ErrorsLoaders.module.scss'; -export default function Error({ title, message }) { +interface Props { + title: string; + message: string; +} + +const Error: React.FunctionComponent = ({ title, message }) => { return (

{title}

{message}
); -} +}; + +export default Error; diff --git a/src/components/common/errors-loaders/NotFoundPage.js b/src/components/common/errors-loaders/NotFoundPage.tsx similarity index 100% rename from src/components/common/errors-loaders/NotFoundPage.js rename to src/components/common/errors-loaders/NotFoundPage.tsx