fix shouldComponentUpdate

This commit is contained in:
yoyo837 2019-05-21 17:51:53 +08:00
parent a1e593b7e7
commit d9ede1b4a5

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;