forked from Frojd/Wagtail-Pipit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace class components with functional components
Fixes Frojd#199
- Loading branch information
Showing
4 changed files
with
55 additions
and
73 deletions.
There are no files selected for viewing
60 changes: 27 additions & 33 deletions
60
Company-Project/frontend/src/containers/ArticlePage/ArticlePage.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 18 additions & 24 deletions
42
Company-Project/frontend/src/containers/HomePage/HomePage.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
20 changes: 7 additions & 13 deletions
20
Company-Project/frontend/src/containers/NotFoundPage/NotFoundPage.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |