You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We should have a state that allows us to temporarily show something like, "Added to your cart" for a few seconds. Not sure what I would name it, maybe hasInteractedWithCart where it's false by default. It will only display for a given number of seconds, and we can pass it a string of what it should say as well.
The text was updated successfully, but these errors were encountered:
dayhaysoos
changed the title
Added To Cart State
Interacted With Cart State
Sep 25, 2020
Hmm, I was thinking of a way to prototype this but I think this is the wrong way to go about something like "Added to your cart". Instead, I would recommend the developer to do this on their Product component:
They should likely be using some sort of global or global-ish state that allows them to add products to a stack when they're added to the cart. After a certain amount of time, they could be cleared off of the stack. Now that I'm writing this, we could also make this stack inside of this library.
Let me know if you want to make this stack or let the end-developers do it. For reference, if we wanted to build it we'd need to do the following:
Add an addedToCartTimer prop or something like that that could be passed to our redux state for future use.
Add an addedToCartStack or something to our redux state.
Add a middleware that sees when addItem is called successfully then adds that product to the addedToCartStack. After that, it starts a setTimeout timer that will do store.dispatch(actions.addedToCartTimerFinished()) which does state.addedToCartStack.shift() to remove the first element of the stack (FIFO)
We should have a state that allows us to temporarily show something like, "Added to your cart" for a few seconds. Not sure what I would name it, maybe hasInteractedWithCart where it's false by default. It will only display for a given number of seconds, and we can pass it a string of what it should say as well.
The text was updated successfully, but these errors were encountered: