-
-
Notifications
You must be signed in to change notification settings - Fork 124
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
Updating url with hash #498
Comments
I see no link nor input field in your linked codesandbox, only a stock create-next-app template. |
I don't know how to share the codesandbox. I am copying the link I get from "copy link" in the share dialog, but you're right, it's just the empty template when I then go to the link. It's simply the basic nextjs template with nuqs installed and page.tsx looks like this: import SearchBar from "./_components/searchbar";
export default function Home() {
return (
<main className="flex min-h-screen flex-col items-center justify-between p-24">
<SearchBar />
<a className="my-8" href="#mysection">
Go to section
</a>
<div id="mysection">
Lorem ipsum dolor sit amet consectetur adipisicing elit.
</div>
</main>
);
} and _components/searchbar looks like this: "use client";
import { useQueryState } from "nuqs";
const SearchBar = () => {
const [query, setQuery] = useQueryState("query");
return (
<input
className="py-2 px-4"
placeholder="Search.."
type="text"
onChange={(e) => setQuery(e.target.value)}
defaultValue={query ?? ""}
/>
);
};
export default SearchBar; |
I can reproduce the issue, with the following notes:
Coupled with the fact that you encountered a similar issue with updating search params via the history method (which I'll dive deeper into this today, and see if I can open a PR to fix this in Next.js. |
Thank you for looking into this so fast. I believe using |
A "fix" for this was started in vercel/next.js#61822, but there are still some major issues with it. As of |
Another PR by the Next.js team should fix this properly: vercel/next.js#62098 I'll wait until it gets merged into a canary release to run the test suite in #500. Unfortunately that means this bug is here to stay in |
Fixed in |
I've tested this nextjs release and it has fixed this issue for me. |
Next.js 14.1.1 was released, but with only a very partial subset of PRs since the previous version, and which doesn't include this fix.. Going to have to wait for the next one I'm afraid (I guess I know why they called it Next now). |
Fixed in Next.js 14.1.2. |
Context
What's your version of
nuqs
?Next.js information (obtained by running
next info
):Are you using:
basePath
option in your Next.js configwindowHistorySupport
flag in your Next.js configDescription
Updating the query param with the setter returned from
useQueryState
causes an error if there's a hash fragment in the url.Reproduction
codesandbox
TypeError: Cannot read properties of null (reading '__PRIVATE_NEXTJS_INTERNALS_TREE')
I was initially following the way as described in the NextJS docs Using the native History API, but I was getting this error when calling window.history.pushState.
This led me to trying this package, but I'm getting the same error.
The text was updated successfully, but these errors were encountered: