Skip to content

Commit

Permalink
Replace class components with functional components
Browse files Browse the repository at this point in the history
Fixes Frojd#199
  • Loading branch information
morrme committed Aug 13, 2020
1 parent c5108fc commit b8ede5a
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 73 deletions.
60 changes: 27 additions & 33 deletions Company-Project/frontend/src/containers/ArticlePage/ArticlePage.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,29 @@
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';

import { basePageWrap } from '../BasePage';
import './ArticlePage.scss';

import Hero from '../../components/Hero';
import RawHtml from '../../components/RawHtml';

class ArticlePage extends PureComponent {
state = {};

static defaultProps = {
title: '',
richText: '',
};

static propTypes = {
title: PropTypes.string.isRequired,
richText: PropTypes.string,
};

render() {
const { title, richText } = this.props;

return (
<div className="ArticlePage">
<Hero title={title} />
<RawHtml html={richText} />
</div>
);
}
}
import React, { PureComponent } from "react";
import PropTypes from "prop-types";

import { basePageWrap } from "../BasePage";
import "./ArticlePage.scss";

import Hero from "../../components/Hero";
import RawHtml from "../../components/RawHtml";

const ArticlePage = ({ title, richText }) => {
return (
<div className="ArticlePage">
<Hero title={title} />
<RawHtml html={richText} />
</div>
);
};

ArticlePage.defaultProps = {
title: "",
richText: "",
};

ArticlePage.propTypes = {
title: PropTypes.string.isRequired,
richText: PropTypes.string,
};

export default basePageWrap(ArticlePage);
6 changes: 3 additions & 3 deletions Company-Project/frontend/src/containers/BasePage/BasePage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import './BasePage.scss';
import React, { PureComponent } from "react";
import PropTypes from "prop-types";
import "./BasePage.scss";

export default class BasePage extends PureComponent {
state = {};
Expand Down
42 changes: 18 additions & 24 deletions Company-Project/frontend/src/containers/HomePage/HomePage.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { basePageWrap } from '../BasePage';
import './HomePage.scss';
import React, { PureComponent } from "react";
import PropTypes from "prop-types";
import { basePageWrap } from "../BasePage";
import "./HomePage.scss";

import Hero from '../../components/Hero';
import Hero from "../../components/Hero";

class HomePage extends PureComponent {
state = {};
const HomePage = ({ title }) => {
return (
<div className="HomePage">
<Hero title={title} />
</div>
);
};

static defaultProps = {
title: '',
};
HomePage.defaultProps = {
title: "",
};

static propTypes = {
title: PropTypes.string.isRequired,
};

render() {
const { title } = this.props;

return (
<div className="HomePage">
<Hero title={title} />
</div>
);
}
}
HomePage.propTypes = {
title: PropTypes.string.isRequired,
};

export default basePageWrap(HomePage);
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
import React, { PureComponent } from 'react';
// import PropTypes from 'prop-types';
import React from "react";
import "./NotFoundPage.scss";

import './NotFoundPage.scss';
const NotFoundPage = () => {
return <div className="NotFoundPage">NotFoundPage</div>;
};

class NotFoundPage extends PureComponent {
state = {};
NotFoundPage.propTypes = {};

static defaultProps = {};

static propTypes = {};

render() {
return <div className="NotFoundPage">NotFoundPage</div>;
}
}
NotFoundPage.defaultProps = {};

export default NotFoundPage;

0 comments on commit b8ede5a

Please sign in to comment.