Next.js Discord

Discord Forum

Why would a server action or redirect trigger a component re-render under 14.2+ but not 14.1.4?

Unanswered
Eurasian Siskin posted this in #help-forum
Open in Discord
Eurasian SiskinOP
I'm on my first NextJS adventure following along Theo's guide [vid](https://www.youtube.com/watch?v=d5x0JCZbAJs) / [repo](https://github.com/t3dotgg/t3gallery/commit/4014399d4d91b9ad0aa0a45153a03549325de833).

The basic setup in this scenario is a server component modal page using a parallel route to display a client component modal for the image --src\app@modal(.)img[id]
The client modal's child has a "delete" button with a server action that deletes the image and uses next/navigation redirect("/") -- server/db/queries deleteImage()
The bug is that before the redirect occurs (or as it occurs?), the modal page and its children re-render, triggering a getImage() request for an image that no longer exists and results in an error.

Some comments suggested using the same older version of Next solves the problem of this redirect not working correctly.

The most relevant thing I've found so far is a blurb in the docs about soft navigation resulting in "partial rendering" (https://nextjs.org/docs/app/building-your-application/routing/linking-and-navigating#4-partial-rendering) that seems to say that this results in not only a rendering of a destination for the navigation, but also a rendering of the page the user is navigating from: "For example, when navigating between two sibling routes, /dashboard/settings and /dashboard/analytics, the settings and analytics pages will be rendered...."

I'd really appreciate some pointers about what's causing the unecessary re-render, or even tips on how I could go about figuring out what's triggering this.

Relevant (I hope) code attached, and thanks for any relevant tips

0 Replies