Shopping cart
json.data do
json.cart partial: ['cart', fragment: true] do
end
yield
endimport { createSlice, createAction } from '@reduxjs/toolkit'
import { updateFragments } from '@thoughtbot/superglue'
export const cartSlice = createSlice({
name: 'cart',
initialState: {},
reducers: {
addToCart: (state, action) => {
....logic to add something to the cart ...
}
},
extraReducers: (builder) => {
builder.addCase(updateFragments, (state, action) => {
// Update the slice with the latest and greatest.
return action.value
})
}
})Last updated