Updating Loader to use hooks

This commit is contained in:
Jeff Avallone 2019-03-26 18:33:40 -04:00
parent 461d8aa7ac
commit 8186e1cf87
3 changed files with 11 additions and 16 deletions

View File

@ -119,7 +119,7 @@ exports[`App rendering an expression 2`] = `
}"
/>
<span
data-component="withI18nextTranslation(Loader)"
data-component="Loader"
data-props="{}"
/>
</DocumentFragment>
@ -200,7 +200,7 @@ exports[`App rendering with an invalid syntax 2`] = `
}"
/>
<span
data-component="withI18nextTranslation(Loader)"
data-component="Loader"
data-props="{}"
/>
</DocumentFragment>

View File

@ -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 }) => (
<div className={ style.loader }>
const Loader = () => {
const { t } = useTranslation();
return <div className={ style.loader }>
<LoaderIcon />
<div className={ style.message }>{ t('Loading...') }</div>
</div>
);
Loader.propTypes = {
t: PropTypes.func.isRequired
</div>;
};
export { Loader };
export default withTranslation()(Loader);
export default Loader;

View File

@ -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(
<Loader t={ mockT } />
<Loader/>
);
expect(asFragment()).toMatchSnapshot();
});