#Router don't want to route !
27 messages · Page 1 of 1 (latest)
🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord
🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in <id:customize>
✅ You can mark a message as the answer for your post with `Right click -> Apps -> Mark Solution`
(if you don't see the option, try refreshing Discord with Ctrl + R)
I'm trying to build an App using nextjs 13 and the new App router feature (https://nextjs.org/blog/next-13-4) :
My problem is about navigation, I'm following the documentation but nothing happened
...
:/
there's an example in the docs which i slightly modified
here's what you need to do
import { useCallback } from "react";
import { usePathname, useRouter, useSearchParams } from "next/navigation";
import Link from "next/link";
export default function Example() {
const router = useRouter();
const pathname = usePathname();
const searchParams = useSearchParams()!;
// Get a new searchParams string by merging the current
// searchParams with a provided key/value pair
const createQueryString = useCallback(
(name: string, value: string) => {
const params = new URLSearchParams(searchParams);
params.set(name, value);
return params.toString();
},
[searchParams]
);
return (
<>
<p>Sort By</p>
{/* using useRouter */}
<button
onClick={() => {
// <pathname>?sort=asc
router.push(pathname + "?" + createQueryString("login", "true"));
}}
>
Login true
</button>
{/* using <Link> */}
<Link
href={
// <pathname>?sort=desc
pathname + "?" + createQueryString("login", "false")
}
>
Login false
</Link>
</>
);
}
still the same ? you're sure it's shoulds work :/?
not-working example 😬
where are you changing to ?login=false?
in the header component
but it's a simple router.push("/number");
look the file ./components/Header.jsx
i can see it on the onclose. but how do you close?
by clicking outside of the modal sry
nothing happens when i click outside
literally used the code i sent above
then i removed the Modal from inside the Link.
you should render the Modal apart else the onClose won't work
i mean the router.push
Ahhh..
This question has been marked as answered! If you have any other questions, feel free to create another post
[Click here](#1121451140320608256 message)