The above will render and allow you to add client side logic for optimistic updates. You can use this cart slice as you normally would with Redux selectors
const cart = useSelector(state => state.cart)
For updates to the backend, add a ujs attribute to a normal form.
defcreate... add to cart logic here...# This helper will retain the `props_at` param when redirecting, which allows the# partial rendering of the `show` page. redirect_back_with_props_at fallback_url: '/'end
The above will POST, and get redirected back to the original page while fetching only the cart to update. This will be picked up by extraReducers and update the entire cart state.