Fix chrome hash link

This commit is contained in:
afc163
2016-07-13 16:06:07 +08:00
parent ce51768fac
commit 1c87f36dd4
+7 -1
View File
@@ -17,10 +17,16 @@ export default class MainContent extends React.Component {
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
} else {
location.hash = location.hash;
this.timer = setTimeout(() => {
document.getElementById(location.hash.replace('#', '')).scrollIntoView();
}, 10);
}
}
componentWillUnmount() {
clearTimeout(this.timer);
}
shouldComponentUpdate(nextProps) {
const pathname = this.props.location.pathname;
return pathname !== nextProps.location.pathname ||