MCPcopy
hub / github.com/vercel/next.js / scrollToHash

Method scrollToHash

packages/next/src/client/index.tsx:164–175  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

162 }
163
164 scrollToHash() {
165 let { hash } = location
166 hash = hash && hash.substring(1)
167 if (!hash) return
168
169 const el: HTMLElement | null = document.getElementById(hash)
170 if (!el) return
171
172 // If we call scrollIntoView() in here without a setTimeout
173 // it won't scroll properly.
174 setTimeout(() => el.scrollIntoView(), 0)
175 }
176
177 render() {
178 if (process.env.NODE_ENV === 'production') {

Callers 2

componentDidMountMethod · 0.95
componentDidUpdateMethod · 0.95

Calls 1

setTimeoutFunction · 0.50

Tested by

no test coverage detected