import { useEffect } from 'react' ; const isMobileSafari = ( ) : boolean => { return /iPad|iPhone|iPod/ . test ( window . navigator . platform ) && /^((?!CriOS).)*Safari/ . test ( window . navigator . userAgent ) ; } ; export default function useScrollRestorationFix ( ) { useEffect ( ( ) => { if ( 'scrollRestoration' in window . history && ! isMobileSafari ( ) ) { window . history . scrollRestoration = 'manual' ; } } , [ ] ) ; }