Browse Source

🐛 Fix scrollama not working after unnecessary update.

pull/16615/head
gxvv 6 years ago
parent
commit
5b8867439a
  1. 10
      site/theme/template/Content/Article.jsx
  2. 10
      site/theme/template/Content/ComponentDoc.jsx

10
site/theme/template/Content/Article.jsx

@ -11,6 +11,16 @@ export default class Article extends React.Component {
intl: PropTypes.object.isRequired,
};
shouldComponentUpdate(nextProps) {
const { location } = this.props;
const { location: nextLocation } = nextProps;
if (nextLocation.pathname === location.pathname) {
return false;
}
return true;
}
onResourceClick = e => {
if (!window.gtag) {
return;

10
site/theme/template/Content/ComponentDoc.jsx

@ -29,6 +29,16 @@ export default class ComponentDoc extends React.Component {
});
}
shouldComponentUpdate(nextProps) {
const { location } = this.props;
const { location: nextLocation } = nextProps;
if (nextLocation.pathname === location.pathname) {
return false;
}
return true;
}
componentWillUnmount() {
clearTimeout(this.pingTimer);
}

Loading…
Cancel
Save