Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: view transition also needs to be ended when the search parameters are changed #48

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/browser-native-events.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect, useRef, useState, use } from 'react'
import { usePathname } from 'next/navigation'
import { usePathname, useSearchParams } from 'next/navigation'
import { useHash } from './use-hash'

// TODO: This implementation might not be complete when there are nested
Expand All @@ -8,6 +8,7 @@ import { useHash } from './use-hash'

export function useBrowserNativeTransitions() {
const pathname = usePathname()
const searchParams = useSearchParams()
const currentPathname = useRef(pathname)

// This is a global state to keep track of the view transition state.
Expand Down Expand Up @@ -75,5 +76,5 @@ export function useBrowserNativeTransitions() {
transitionRef.current[1]()
transitionRef.current = null
}
}, [hash, pathname]);
}, [hash, pathname, searchParams]);
}