Merge pull request #16712 from yoyo837/fix-16706

fix shouldComponentUpdate
This commit is contained in:
偏右 2019-05-21 17:56:09 +08:00 committed by GitHub
commit 8a91c94c4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -29,11 +29,17 @@ export default class ComponentDoc extends React.Component {
});
}
shouldComponentUpdate(nextProps) {
shouldComponentUpdate(nextProps, nextState) {
const { location } = this.props;
const { location: nextLocation } = nextProps;
const { expandAll, showRiddleButton } = this.state;
const { expandAll: nextExpandAll, showRiddleButton: nextShowRiddleButton } = nextState;
if (nextLocation.pathname === location.pathname) {
if (
nextLocation.pathname === location.pathname &&
expandAll === nextExpandAll &&
showRiddleButton === nextShowRiddleButton
) {
return false;
}
return true;