diff --git a/src/components/structures/HomePage.js b/src/components/structures/HomePage.js index 27a0b6bf49..5df58305e6 100644 --- a/src/components/structures/HomePage.js +++ b/src/components/structures/HomePage.js @@ -18,40 +18,36 @@ limitations under the License. 'use strict'; import React from 'react'; +import PropTypes from 'prop-types'; import request from 'browser-request'; import { _t } from '../../languageHandler'; import sanitizeHtml from 'sanitize-html'; import sdk from '../../index'; -module.exports = React.createClass({ - displayName: 'HomePage', +class HomePage extends React.Component { + displayName = 'HomePage'; - propTypes: { + static propTypes = { // URL base of the team server. Optional. - teamServerUrl: React.PropTypes.string, + teamServerUrl: PropTypes.string, // Team token. Optional. If set, used to get the static homepage of the team // associated. If unset, homePageUrl will be used. - teamToken: React.PropTypes.string, + teamToken: PropTypes.string, // URL to use as the iFrame src. Defaults to /home.html. - homePageUrl: React.PropTypes.string, - }, + homePageUrl: PropTypes.string, + }; - getInitialState: function() { - return { + state = { iframeSrc: '', page: '', - }; - }, + }; - translate: function(s) { - s = sanitizeHtml(_t(s)); - // ugly fix for https://github.com/vector-im/riot-web/issues/4243 - s = s.replace(/Riot\.im/, 'Riot.im'); - s = s.replace(/\[matrix\]/, '[matrix]'); - return s; - }, + translate(s) { + // default implementation - skins may wish to extend this + return sanitizeHtml(_t(s)); + } - componentWillMount: function() { + componentWillMount() { this._unmounted = false; if (this.props.teamToken && this.props.teamServerUrl) { @@ -84,13 +80,13 @@ module.exports = React.createClass({ } ); } - }, + } - componentWillUnmount: function() { + componentWillUnmount() { this._unmounted = true; - }, + } - render: function() { + render() { if (this.state.iframeSrc) { return (
@@ -108,4 +104,6 @@ module.exports = React.createClass({ ); } } -}); +} + +module.exports = HomePage; \ No newline at end of file