I need to reset current state to initial state. But all my attempts were unsuccessful. How can I do it using redux-toolkit?
const showOnReviewSlice = createSlice({ name: 'showOnReview', initialState: { returned: [], }, reducers: { reset(state) { //here I need to reset state of current slice }, }, });
Something like this:
const intialState = { returned: [] } const showOnReviewSlice = createSlice({ name: 'showOnReview', initialState, reducers: { reset: () => initialState } });
This worked for me (mid-late 2020). Formatted with your code context as an example.
const initialState = { returned: [], }; const showOnReviewSlice = createSlice({ name: 'showOnReview', initialState, reducers: { reset: () => initialState, }, });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With