Revert "Adding a HOC for using StaticQuery"
This reverts commit 3b11fcb0b6.
This commit is contained in:
@@ -4,7 +4,13 @@ exports[`Footer rendering 1`] = `
|
||||
ShallowWrapper {
|
||||
Symbol(enzyme.__root__): [Circular],
|
||||
Symbol(enzyme.__unrendered__): <Footer
|
||||
buildId="abc-123"
|
||||
site={
|
||||
Object {
|
||||
"siteMetadata": Object {
|
||||
"buildId": "abc-123",
|
||||
},
|
||||
}
|
||||
}
|
||||
t={[Function]}
|
||||
/>,
|
||||
Symbol(enzyme.__renderer__): Object {
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { graphql } from 'gatsby';
|
||||
import { StaticQuery, graphql } from 'gatsby';
|
||||
import { withNamespaces, Trans } from 'react-i18next';
|
||||
|
||||
import withQuery from 'lib/with-query';
|
||||
|
||||
import style from './style.module.css';
|
||||
|
||||
const query = graphql`
|
||||
@@ -17,7 +15,7 @@ const query = graphql`
|
||||
}
|
||||
`;
|
||||
|
||||
export const Footer = ({ t, buildId }) => (
|
||||
export const Footer = ({ t, site: { siteMetadata } }) => (
|
||||
<footer className={ style.footer }>
|
||||
<ul className={ style.list }>
|
||||
<li>
|
||||
@@ -35,19 +33,22 @@ export const Footer = ({ t, buildId }) => (
|
||||
</li>
|
||||
</ul>
|
||||
<div className={ style.buildId }>
|
||||
{ buildId }
|
||||
{ siteMetadata.buildId }
|
||||
</div>
|
||||
</footer>
|
||||
);
|
||||
|
||||
Footer.propTypes = {
|
||||
t: PropTypes.func.isRequired,
|
||||
buildId: PropTypes.string.isRequired
|
||||
site: PropTypes.shape({
|
||||
siteMetadata: PropTypes.shape({
|
||||
buildId: PropTypes.string.isRequired
|
||||
}).isRequired
|
||||
}).isRequired
|
||||
};
|
||||
|
||||
export default [
|
||||
withQuery(query, {
|
||||
toProps: ({ site: { siteMetadata } }) => siteMetadata
|
||||
}),
|
||||
withNamespaces()
|
||||
].reduce((component, fn) => fn(component), Footer);
|
||||
export default withNamespaces()(props => (
|
||||
<StaticQuery query={ query } render={ data => (
|
||||
<Footer { ...props } { ...data } />
|
||||
) } />
|
||||
));
|
||||
|
||||
@@ -7,7 +7,7 @@ import { Footer } from 'components/Footer';
|
||||
describe('Footer', () => {
|
||||
test('rendering', () => {
|
||||
const component = shallow(
|
||||
<Footer buildId="abc-123" t={ mockT } />
|
||||
<Footer site={{ siteMetadata: { buildId: 'abc-123' } }} t={ mockT } />
|
||||
);
|
||||
expect(component).toMatchSnapshot();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user