Converting IndexPage to a class

This commit is contained in:
Jeff Avallone 2019-01-15 20:36:45 -05:00
parent 9200c1a8e3
commit e77763d0b0
2 changed files with 38 additions and 30 deletions

View File

@ -39,24 +39,8 @@ const readURLHash = (location, defaultSyntax) => {
} }
}; };
export const IndexPage = ({ class IndexPage extends React.PureComponent {
location, static propTypes = {
data: { site: { siteMetadata } }
}) => <>
<Metadata/>
<noscript>
<Message type="error" heading="JavaScript Required">
<p>You need JavaScript to use Regexper.</p>
<p>If you have concerns regarding the use of tracking code on Regexper,
please see the <Link to="/privacy">Privacy Policy</Link>.</p>
</Message>
</noscript>
<App
syntaxList={ siteMetadata.syntaxList }
{ ...readURLHash(location, siteMetadata.defaultSyntax) } />
</>;
IndexPage.propTypes = {
location: PropTypes.object, location: PropTypes.object,
data: PropTypes.shape({ data: PropTypes.shape({
site: PropTypes.shape({ site: PropTypes.shape({
@ -69,6 +53,30 @@ IndexPage.propTypes = {
}) })
}) })
}) })
}; }
render() {
const {
location,
data: { site: { siteMetadata } }
} = this.props;
return <>
<Metadata/>
<noscript>
<Message type="error" heading="JavaScript Required">
<p>You need JavaScript to use Regexper.</p>
<p>
If you have concerns regarding the use of tracking code on Regexper,
please see the <Link to="/privacy">Privacy Policy</Link>.
</p>
</Message>
</noscript>
<App
syntaxList={ siteMetadata.syntaxList }
{ ...readURLHash(location, siteMetadata.defaultSyntax) } />
</>;
}
}
export default IndexPage; export default IndexPage;

View File

@ -1,7 +1,7 @@
import React from 'react'; import React from 'react';
import { shallow } from 'enzyme'; import { shallow } from 'enzyme';
import { IndexPage } from 'pages/index'; import IndexPage from 'pages/index';
const queryResult = { const queryResult = {
site: { site: {