Created
August 6, 2020 02:41
-
-
Save Rajatgms/383c4576c04f630d839ba799071a610b to your computer and use it in GitHub Desktop.
use Payload Creator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const todosSlice = createSlice({ | |
name: 'cart', | |
initialState: [], | |
reducers: { | |
addItem: { | |
reducer: (state, action) => { | |
state.push(action.payload) | |
}, | |
prepare: item => { | |
const id = nanoid() | |
return { payload: { id, ...item } } | |
} | |
} | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment