Next.js Discord

Discord Forum

Threejs with 'usePathname' hook of NextJS

Answered
Atlantic cod posted this in #help-forum
Open in Discord
Atlantic codOP
I'm using react hooks for threejs and nextjs hooks to get my camera change it's position as route changes. for now I'm using simple else-if contraption to change value and have plan to implement more functions. But I have to refresh the page to get the changes to take effect when navigating through pages which defeats the whole purpose of using nextjs soft reload.
Any insight regarding this would be highly appreciated.
Answered by @ts-ignore
add the pathname in useEffect dependency
View full answer

5 Replies

Answer
@@ts-ignore add the pathname in useEffect dependency
Atlantic codOP
yep, did that acc to nextjs docs from the beginning. but no response.
what do you mean by "no response"? Your useEffect should be fired
@fuma what do you mean by "no response"? Your `useEffect` should be fired
Atlantic codOP
ah yes, it's fixed now. moved the element from layout to individual page.tsx file. bit glitchy but yeah.. endless cycle of bug fixes I guess
thanks both of you ✌️