From bfe1393524bc5910bae058b75433cdcb1a4e30da Mon Sep 17 00:00:00 2001 From: jljsj Date: Mon, 9 Apr 2018 11:20:55 +0800 Subject: [PATCH] fix #1215 --- package.json | 2 +- src/layouts/BasicLayout.js | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 9d22bc33..102a2d2c 100755 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "classnames": "^2.2.5", "dva": "^2.1.0", "dva-loading": "^1.0.4", - "enquire-js": "^0.1.1", + "enquire-js": "^0.2.1", "lodash": "^4.17.4", "lodash-decorators": "^4.4.1", "moment": "^2.19.1", diff --git a/src/layouts/BasicLayout.js b/src/layouts/BasicLayout.js index 8a92c6cd..930ffdb3 100644 --- a/src/layouts/BasicLayout.js +++ b/src/layouts/BasicLayout.js @@ -6,7 +6,7 @@ import { connect } from 'dva'; import { Route, Redirect, Switch, routerRedux } from 'dva/router'; import { ContainerQuery } from 'react-container-query'; import classNames from 'classnames'; -import { enquireScreen } from 'enquire-js'; +import { enquireScreen, unenquireScreen } from 'enquire-js'; import GlobalHeader from '../components/GlobalHeader'; import GlobalFooter from '../components/GlobalFooter'; import SiderMenu from '../components/SiderMenu'; @@ -99,7 +99,7 @@ class BasicLayout extends React.PureComponent { }; } componentDidMount() { - enquireScreen(mobile => { + this.enquireHandler = enquireScreen(mobile => { this.setState({ isMobile: mobile, }); @@ -108,6 +108,9 @@ class BasicLayout extends React.PureComponent { type: 'user/fetchCurrent', }); } + componentWillUnmount(){ + unenquireScreen(this.enquireHandler); + } getPageTitle() { const { routerData, location } = this.props; const { pathname } = location; -- GitLab