diff --git a/package.json b/package.json index 9d22bc33ffa6b1fdbfbdf15c8a2c612c97e4e2ab..102a2d2c9e35c32bc32efe9afbb6eed6e5bc53c0 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 8a92c6cdba43b3f84e41b87ba06d7ed77ef07c42..930ffdb3d4adafc7bb0446113def6286a1b591a5 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;