aboutsummaryrefslogtreecommitdiff
path: root/src/client/react/components/page
diff options
context:
space:
mode:
authorNoah Loomans <noahloomans@gmail.com>2018-02-09 17:04:12 +0100
committerNoah Loomans <noahloomans@gmail.com>2018-02-09 17:04:12 +0100
commit6926de1108b1a084e133d5f8363f080d7c20a99f (patch)
treece27ac5a024e6a0e342037d3ea03ddf7ca6c3c82 /src/client/react/components/page
parent8d5bccc8984618c9282e9592882835819306fa07 (diff)
Use classes instead of stateless functions for Components
Diffstat (limited to 'src/client/react/components/page')
-rw-r--r--src/client/react/components/page/Index.js22
-rw-r--r--src/client/react/components/page/User.js50
2 files changed, 39 insertions, 33 deletions
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 = () => (
- <div className="page-index">
- <div className="container">
- <img src="/icons/mml-logo.png" alt="Metis" />
- <Search />
- <HelpBox />
- </div>
- </div>
-);
+class IndexPage extends React.Component {
+ render() {
+ return (
+ <div className="page-index">
+ <div className="container">
+ <img src="/icons/mml-logo.png" alt="Metis" />
+ <Search />
+ <HelpBox />
+ </div>
+ </div>
+ );
+ }
+}
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 <Redirect to="/" />;
- }
+ render() {
+ const user = userFromMatch(this.props.match);
+
+ if (!user) {
+ // Invalid user, redirect to index.
+ return <Redirect to="/" />;
+ }
- return (
- <div className="page-user">
- <div className="search-wrapper">
- <div className="search-container">
- <Search />
+ return (
+ <div className="page-user">
+ <div className="search-wrapper">
+ <div className="search-container">
+ <Search />
+ </div>
</div>
- </div>
- <div className="menu">
- <div className="menu-container">
- <WeekSelector />
+ <div className="menu">
+ <div className="menu-container">
+ <WeekSelector />
+ </div>
</div>
+ <View />
</div>
- <View />
- </div>
- );
-};
-
-UserPage.propTypes = {
- // react-router
- match: PropTypes.object.isRequired,
-};
+ );
+ }
+}
export default UserPage;