<commit_before>import React, {useEffect} from 'react';
import {registerComponent} from '../../lib/vulcan-lib';
import { useSubscribedLocation } from '../../lib/routeUtil';

// Scroll restoration based on https://reacttraining.com/react-router/web/guides/scroll-restoration.
export default function ScrollToTop() {
  const { pathname } = useSubscribedLocation();

  useEffect(() => {
    window.scrollTo(0, 0);
  }, [pathname]);<commit_msg>Fix spurious scroll-to-top<commit_after>import React, {useEffect, useRef} from 'react';
import {registerComponent} from '../../lib/vulcan-lib';
import { useSubscribedLocation } from '../../lib/routeUtil';

// Scroll restoration based on https://reacttraining.com/react-router/web/guides/scroll-restoration.
export default function ScrollToTop() {
  const { pathname } = useSubscribedLocation();
  const didMountRef = useRef(false)
  useEffect(() => {
    if (didMountRef.current) {
      window.scrollTo(0, 0);
    } else didMountRef.current = true
  }, [pathname])
{'fraction_non_alphanumeric': 0.15737051792828685, 'fraction_numerical': 0.00398406374501992, 'mean_word_length': 4.374331550802139, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3312219', 'n_tokens_mistral': 302, 'n_tokens_neox': 297, 'n_words': 68}