mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Scroll to the hash only if there's one after an error. (#2224)
This commit is contained in:
parent
ad4ec554ca
commit
4726c4352e
|
@ -44,13 +44,15 @@ class Container extends Component {
|
|||
|
||||
scrollToHash () {
|
||||
const { hash } = this.props
|
||||
if (!hash) return
|
||||
|
||||
const el = document.getElementById(hash)
|
||||
if (el) {
|
||||
if (!el) return
|
||||
|
||||
// If we call scrollIntoView() in here without a setTimeout
|
||||
// it won't scroll properly.
|
||||
setTimeout(() => el.scrollIntoView(), 0)
|
||||
}
|
||||
}
|
||||
|
||||
shouldComponentUpdate (nextProps) {
|
||||
// need this check not to rerender component which has already thrown an error
|
||||
|
|
Loading…
Reference in a new issue