TypeError: destroy is not a function on navigation
Unanswered
California pilchard posted this in #help-forum
California pilchardOP
I am trying to navigate to a dynamic route when the user clicks on the button, but I get
However, upon refreshing I am able to see the dynamic page
TypeError: destroy is not a function on navigation spammed in my console which is confusing about whats going wrong.However, upon refreshing I am able to see the dynamic page
const navigate = (id) => {
router.push(`/dashboard/${id}`)
}<button onClick={(e)=>navigate(id)}>Configure</button>25 Replies
California pilchardOP
.
European sprat
Show the full code for that
California pilchardOP
I used useSWR hook instead of fetch in useEffect, it worked fine
Pacific cod
Why don't you use next in built Link component?
using next/link is the way to go here
California pilchardOP
I used that in the first approach, it failed
Then I went to useRouter approach
To fix this, you can either wrap your async function in another function and call it inside the useEffect hook, or use the .then() method to handle the Promise resolution. For example:
for example
router.push(/dashboard/${id}).then(() => { // Do something after navigation }) }, [id])or use navigate
like this:
import { useNavigate } from 'react-router-dom';
<button onClick={(e)=>navigate(id)}>Configure</button>does
react-router-dom work with next? i thought they made their own router...@riský does `react-router-dom` work with next? i thought they made their own router...
React Router and Next.js can be used together, but there are some important considerations to keep in mind.
React Router (specifically react-router-dom) is primarily designed for client-side routing in React applications. Next.js, on the other hand, is a framework for building server-rendered React applications, and it also provides its own routing system through its next/router module.
React Router (specifically react-router-dom) is primarily designed for client-side routing in React applications. Next.js, on the other hand, is a framework for building server-rendered React applications, and it also provides its own routing system through its next/router module.
Please note that the landscape of web development technologies can change rapidly, and there may have been updates or changes to both Next.js and react-router-dom
@Bashamega React Router and Next.js can be used together, but there are some important considerations to keep in mind.
React Router (specifically react-router-dom) is primarily designed for client-side routing in React applications. Next.js, on the other hand, is a framework for building server-rendered React applications, and it also provides its own routing system through its next/router module.
this is just wrong. nextjs brings their own client-side router which is tightly coupled and well-integrated with their server-side features, do NOT use react-router-dom with next.js
it's as bad as using jquery in react
it will likely lead to inconsistencies in state updates and unexpected behaviours
i have noticed that you have posted several AI-generated answers or answers that look AI-generated recently. while I'm fine with that, please ensure the quality and accuracy of the answer is good enough before posting. misinformation like this won't be tolerated by the staff, and LLMs do generate misinformation a lot
European sprat
Don't use ChatGPT like this lol
so do ensure to double check everything before posting
ok sorry