Set the same session flash value multiple times #4243
Unanswered
piotrkulpinski
asked this question in
Q&A
Replies: 2 comments 5 replies
-
The session is an object, if you use the same key for two values only the last one will remain. let session = {}
session.flash = "message 1"
session.flash = "message 2"
console.log(session.flash) // here the value is "message 2" So the solution is to use different keys or store an array of values. session.flash("notification", [...session.get("notification"), "new message"]) This way, you will keep previous messages on the session, and once you read it remember to consider it an array of strings. |
Beta Was this translation helpful? Give feedback.
2 replies
-
Does anyone have any solution to that? |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi!
I'm trying to create a notification/toast system based on the Remix session flash feature:
https://remix.run/docs/en/v1/api/remix#sessionflashkey-value
Unfortunately, it only allows me to send a flash message once if the value is the same.
Hence, this works:
...while it doesn't:
Is there any solution to that?
Beta Was this translation helpful? Give feedback.
All reactions