🗒️
ブラウザバックで表示高さにスクロールする処理を止める
window.history.scrollRestorationプロパティを使用して、Reactの再レンダリングによってスクロール位置が復元されるのを無効にする。
if ('scrollRestoration' in window.history) {
window.history.scrollRestoration = 'manual';
}
scrollRestorationプロパティに'manual'を設定することで、ブラウザの戻る/進むボタンを押した際に、スクロール位置が自動的に復元されなくなる。
Discussion