From 6926de1108b1a084e133d5f8363f080d7c20a99f Mon Sep 17 00:00:00 2001 From: Noah Loomans Date: Fri, 9 Feb 2018 17:04:12 +0100 Subject: Use classes instead of stateless functions for Components --- src/client/react/components/page/Index.js | 22 ++++++++------ src/client/react/components/page/User.js | 50 ++++++++++++++++--------------- 2 files changed, 39 insertions(+), 33 deletions(-) (limited to 'src/client/react/components/page') diff --git a/src/client/react/components/page/Index.js b/src/client/react/components/page/Index.js index e5e47c5..c48ebe0 100644 --- a/src/client/react/components/page/Index.js +++ b/src/client/react/components/page/Index.js @@ -2,14 +2,18 @@ import React from 'react'; import Search from '../container/Search'; import HelpBox from '../container/HelpBox'; -const IndexPage = () => ( -
-
- Metis - - -
-
-); +class IndexPage extends React.Component { + render() { + return ( +
+
+ Metis + + +
+
+ ); + } +} export default IndexPage; diff --git a/src/client/react/components/page/User.js b/src/client/react/components/page/User.js index ae1dcc2..b520f90 100644 --- a/src/client/react/components/page/User.js +++ b/src/client/react/components/page/User.js @@ -6,34 +6,36 @@ import View from '../container/View'; import { userFromMatch } from '../../lib/url'; import WeekSelector from '../container/WeekSelector'; -const UserPage = ({ match }) => { - const user = userFromMatch(match); +class UserPage extends React.Component { + static propTypes = { + // react-router + match: PropTypes.object.isRequired, + }; - if (!user) { - // Invalid user, redirect to index. - return ; - } + render() { + const user = userFromMatch(this.props.match); + + if (!user) { + // Invalid user, redirect to index. + return ; + } - return ( -
-
-
- + return ( +
+
+
+ +
-
-
-
- +
+
+ +
+
- -
- ); -}; - -UserPage.propTypes = { - // react-router - match: PropTypes.object.isRequired, -}; + ); + } +} export default UserPage; -- cgit v1.1