diff --git a/site/component/MainContent/index.jsx b/site/component/MainContent/index.jsx index 656d7483eb..352b4c21c0 100644 --- a/site/component/MainContent/index.jsx +++ b/site/component/MainContent/index.jsx @@ -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);