Layout with API call rerun with dyanamic route
Unanswered
Japanese Bobtail posted this in #help-forum
Japanese BobtailOP
I'm calling a playlists API in layout.tsx and passing the results to the sidebar. The sidebar then maps the array into Link components that href to dynamic routes. However, when I click on a playlist link, it loads the main area but also triggers the API call in the layout again. I'm unsure how to prevent this redundant API call. All components are client. All directory structure -
π movies
β£ π page.tsx
β£ π layout.tsx
β£ π sidebar.tsx
β π [playlist_id]
β π page.tsx
//sidebar.tsx
π movies
β£ π page.tsx
β£ π layout.tsx
β£ π sidebar.tsx
β π [playlist_id]
β π page.tsx
//sidebar.tsx
export default function Sidebar({ *categories* }) {
β¦
<Link href={`/movies/${category.playlist_id}`}>