#Best practices for passing an array from one page to another

10 messages · Page 1 of 1 (latest)

modest perch
#

Hey everyone, I have a server-side rendered page where the user needs to select some options before proceeding to the order page. I’m wondering if there’s a way to share everything the user has selected and make a request on the order page to calculate the total amount.

For example: I select option A and proceed to the order page. On the order page, I need to calculate the total for A (and potentially for B, C, or D if there are other selections).

How can I achieve this? The only solution I can think of is making the page client-side and using state management like Redux or another approach

rigid crystalBOT
#

🔎 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)

still sinew
#

you can use the url as state
pass everything from one page to another using query params

compact jasper
modest perch
plucky plume
#

@modest perch you should use client side state management

modest perch
# plucky plume <@713793871401844816> you should use client side state management

this is already fixed
the problem now is: I have a list of products stored in cookies. My server-side page retrieves this info and sends a POST request to the API. The API returns some data and I format this data. After formatting, I send the information to the client, whose responsibility is to simply display the data. But for now, I can't achieve this because I have a delete button that removes a product. After the product is deleted on the client side, the server side doesn't hear this change so the product never disappears from the page 😦

modest perch
#

just added router.refresh()

#

with transition using useTransition from react

#

thanks guys