Converting IndexPage to a class
This commit is contained in:
parent
9200c1a8e3
commit
e77763d0b0
@ -39,24 +39,8 @@ const readURLHash = (location, defaultSyntax) => {
|
||||
}
|
||||
};
|
||||
|
||||
export const IndexPage = ({
|
||||
location,
|
||||
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 = {
|
||||
class IndexPage extends React.PureComponent {
|
||||
static propTypes = {
|
||||
location: PropTypes.object,
|
||||
data: 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;
|
||||
|
@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
|
||||
import { IndexPage } from 'pages/index';
|
||||
import IndexPage from 'pages/index';
|
||||
|
||||
const queryResult = {
|
||||
site: {
|
||||
|
Loading…
Reference in New Issue
Block a user