site: improve performance

pull/1477/head
Benjy Cui 9 years ago
parent dbafd4ef63
commit 8f7c8fb9c0

@ -7,11 +7,19 @@ const SubMenu = Menu.SubMenu;
export default class MainContent extends React.Component {
componentDidMount() {
this.componentDidUpdate();
this.scrollToAnchor(this.props);
}
componentDidUpdate() {
const scrollTo = this.props.location.query.scrollTo;
shouldComponentUpdate(nextProps) {
this.scrollToAnchor(nextProps);
const pathname = this.props.location.pathname;
return pathname !== nextProps.location.pathname ||
/^\/components\//i.test(pathname);
}
scrollToAnchor(props) {
const scrollTo = props.location.query.scrollTo;
if (scrollTo !== undefined) {
const target = document.getElementById(scrollTo);

Loading…
Cancel
Save