From 8186e1cf875afde3da4075c9f44c3284776e0bf9 Mon Sep 17 00:00:00 2001 From: Jeff Avallone Date: Tue, 26 Mar 2019 18:33:40 -0400 Subject: [PATCH] Updating Loader to use hooks --- src/components/App/__snapshots__/test.js.snap | 4 ++-- src/components/Loader/index.js | 18 +++++++----------- src/components/Loader/test.js | 5 ++--- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/components/App/__snapshots__/test.js.snap b/src/components/App/__snapshots__/test.js.snap index 57e33f4..6f8f900 100644 --- a/src/components/App/__snapshots__/test.js.snap +++ b/src/components/App/__snapshots__/test.js.snap @@ -119,7 +119,7 @@ exports[`App rendering an expression 2`] = ` }" /> @@ -200,7 +200,7 @@ exports[`App rendering with an invalid syntax 2`] = ` }" /> diff --git a/src/components/Loader/index.js b/src/components/Loader/index.js index 83336d9..1fa58dc 100644 --- a/src/components/Loader/index.js +++ b/src/components/Loader/index.js @@ -1,21 +1,17 @@ import React from 'react'; -import PropTypes from 'prop-types'; -import { withTranslation } from 'react-i18next'; +import { useTranslation } from 'react-i18next'; import LoaderIcon from 'react-feather/dist/icons/loader'; import style from './style.module.css'; -const Loader = ({ t }) => ( -
+const Loader = () => { + const { t } = useTranslation(); + + return
{ t('Loading...') }
-
-); - -Loader.propTypes = { - t: PropTypes.func.isRequired +
; }; -export { Loader }; -export default withTranslation()(Loader); +export default Loader; diff --git a/src/components/Loader/test.js b/src/components/Loader/test.js index 49231b8..3becb8b 100644 --- a/src/components/Loader/test.js +++ b/src/components/Loader/test.js @@ -1,15 +1,14 @@ import React from 'react'; import { render } from 'react-testing-library'; -import { mockT } from 'i18n'; -import { Loader } from 'components/Loader'; +import Loader from 'components/Loader'; describe('Loader', () => { test('rendering', () => { // Using full rendering here since styles for this depend on the structure // of the SVG. const { asFragment } = render( - + ); expect(asFragment()).toMatchSnapshot(); });