From e77763d0b058bbb5e711f3f22965383c4d2770f7 Mon Sep 17 00:00:00 2001 From: Jeff Avallone Date: Tue, 15 Jan 2019 20:36:45 -0500 Subject: [PATCH] Converting IndexPage to a class --- src/pages/index.js | 66 +++++++++++++++++++++++------------------ src/pages/index.test.js | 2 +- 2 files changed, 38 insertions(+), 30 deletions(-) diff --git a/src/pages/index.js b/src/pages/index.js index a9c36e2..a215ea4 100644 --- a/src/pages/index.js +++ b/src/pages/index.js @@ -39,36 +39,44 @@ const readURLHash = (location, defaultSyntax) => { } }; -export const IndexPage = ({ - location, - data: { site: { siteMetadata } } -}) => <> - - - -; - -IndexPage.propTypes = { - location: PropTypes.object, - data: PropTypes.shape({ - site: PropTypes.shape({ - siteMetadata: PropTypes.shape({ - defaultSyntax: PropTypes.string, - syntaxList: PropTypes.arrayOf(PropTypes.shape({ - id: PropTypes.string, - label: PropTypes.string - })) +class IndexPage extends React.PureComponent { + static propTypes = { + location: PropTypes.object, + data: PropTypes.shape({ + site: PropTypes.shape({ + siteMetadata: PropTypes.shape({ + defaultSyntax: PropTypes.string, + syntaxList: PropTypes.arrayOf(PropTypes.shape({ + id: PropTypes.string, + label: PropTypes.string + })) + }) }) }) - }) -}; + } + + render() { + const { + location, + data: { site: { siteMetadata } } + } = this.props; + + return <> + + + + ; + } +} export default IndexPage; diff --git a/src/pages/index.test.js b/src/pages/index.test.js index e2f6f9f..6c909f1 100644 --- a/src/pages/index.test.js +++ b/src/pages/index.test.js @@ -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: {