diff --git a/src/pages/XxxAnswersPage/XxxAnswersPage.tsx b/src/pages/XxxAnswersPage/XxxAnswersPage.tsx index 4524ce8..ecf3dff 100644 --- a/src/pages/XxxAnswersPage/XxxAnswersPage.tsx +++ b/src/pages/XxxAnswersPage/XxxAnswersPage.tsx @@ -44,9 +44,8 @@ class XxxAnswersPage extends React.Component< componentDidMount() { this.getQuestionId(); this.getQuestion(); - } - - componentWillMount() { + + // Set up history listener after component is mounted this.unlisten = this.props.history.listen(() => { console.log("url changed"); this.getQuestionId(); @@ -62,7 +61,7 @@ class XxxAnswersPage extends React.Component< let id: string = ""; let params: XxxAnswersPageSearchParams; params = this.props.match.params; - if (params.hasOwnProperty("id") && typeof params.id === "string") { + if (Object.prototype.hasOwnProperty.call(params, "id") && typeof params.id === "string") { this.questionId = params.id; } return id; @@ -98,7 +97,7 @@ class XxxAnswersPage extends React.Component< response.json().then(data => { if ( typeof data === "object" && - data.hasOwnProperty("items") && + Object.prototype.hasOwnProperty.call(data, "items") && Array.isArray(data.items) && data.items.length > 0 ) { @@ -138,7 +137,7 @@ class XxxAnswersPage extends React.Component< response.json().then(data => { if ( typeof data === "object" && - data.hasOwnProperty("items") && + Object.prototype.hasOwnProperty.call(data, "items") && Array.isArray(data.items) && data.items.length > 0 ) { diff --git a/src/pages/XxxQuestionsPage/XxxQuestionsPage.tsx b/src/pages/XxxQuestionsPage/XxxQuestionsPage.tsx index eeea9f0..c631e67 100644 --- a/src/pages/XxxQuestionsPage/XxxQuestionsPage.tsx +++ b/src/pages/XxxQuestionsPage/XxxQuestionsPage.tsx @@ -50,9 +50,8 @@ class XxxQuestionsPage extends React.Component< componentDidMount() { this.readUrlQueryString(this.props.location.search); this.getQuestions(); - } - - componentWillMount() { + + // Set up history listener after component is mounted this.unlisten = this.props.history.listen(location => { this.readUrlQueryString(location.search); this.getQuestions(); @@ -104,7 +103,7 @@ class XxxQuestionsPage extends React.Component< response.json().then(data => { if ( typeof data === "object" && - data.hasOwnProperty("items") && + Object.prototype.hasOwnProperty.call(data, "items") && Array.isArray(data.items) && data.items.length > 0 ) {