-
Notifications
You must be signed in to change notification settings - Fork 4k
Add HashContext and HashProvider for managing URL hash state #3541
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
Conversation
|
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements a HashContext and HashProvider system to properly manage URL hash state changes for same-page links. The existing useHash
hook was not triggering updates when clicking links with hashes on the same page, so this solution replaces the previous implementation with a context-based approach that manually tracks hash changes through the Link component.
- Replaces the existing
useHash
hook implementation with a context-based solution - Adds HashProvider to the application's root context providers
- Integrates hash tracking into the Link component's onClick handler
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
packages/gitbook/src/components/primitives/Link.tsx | Adds HashContext integration and calls updateHashFromUrl in onClick handler |
packages/gitbook/src/components/hooks/useHash.tsx | New file implementing HashContext, HashProvider, and updated useHash hook |
packages/gitbook/src/components/hooks/useHash.ts | Removes the old useHash implementation |
packages/gitbook/src/components/RootLayout/ClientContexts.tsx | Wraps the app with HashProvider |
ad7ccc0
to
51539e3
Compare
Link with an hash on the same page were not triggering change from the
useHash
hook.