Skip to content

Commit

Permalink
[Beta] Avoid grey screen on Safari iOS swipe
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Sep 10, 2022
1 parent 7e8447a commit bde7b60
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions beta/src/pages/_app.tsx
Expand Up @@ -25,6 +25,15 @@ if (typeof window !== 'undefined') {

export default function MyApp({Component, pageProps}: AppProps) {
const router = useRouter();

React.useEffect(() => {
// This is kind of a lie.
// We still rely on the manual Next.js scrollRestoration logic.
// However, we *also* don't want Safari grey screen during the back swipe gesture.
// Seems like it doesn't hurt to enable auto restore *and* Next.js logic at the same time.
history.scrollRestoration = 'auto';
}, []);

React.useEffect(() => {
const handleRouteChange = (url: string) => {
ga('set', 'page', url);
Expand Down

0 comments on commit bde7b60

Please sign in to comment.