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
12
lib/app.js
12
lib/app.js
|
@ -44,12 +44,14 @@ class Container extends Component {
|
|||
|
||||
scrollToHash () {
|
||||
const { hash } = this.props
|
||||
if (!hash) return
|
||||
|
||||
const el = document.getElementById(hash)
|
||||
if (el) {
|
||||
// If we call scrollIntoView() in here without a setTimeout
|
||||
// it won't scroll properly.
|
||||
setTimeout(() => el.scrollIntoView(), 0)
|
||||
}
|
||||
if (!el) return
|
||||
|
||||
// If we call scrollIntoView() in here without a setTimeout
|
||||
// it won't scroll properly.
|
||||
setTimeout(() => el.scrollIntoView(), 0)
|
||||
}
|
||||
|
||||
shouldComponentUpdate (nextProps) {
|
||||
|
|
Loading…
Reference in a new issue