Created
August 3, 2020 14:54
-
-
Save Rajatgms/8cfad2081f292a896cee7d42b3411a90 to your computer and use it in GitHub Desktop.
createSlice
This file contains 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
import { createSlice } from '@reduxjs/toolkit'; | |
const initialAlert = { | |
variant: '', | |
message: '', | |
}; | |
const notifySlice = createSlice({ | |
name: 'notify', | |
initialState: initialAlert, | |
reducers: { | |
success: (state, action) => ( | |
{ variant: 'success', message: action.payload } | |
), | |
error: (state, action) => ( | |
{ variant: 'danger', message: action.payload } | |
), | |
reset: () => initialAlert, | |
}, | |
}); | |
const {actions, reducer} = notifySlice; | |
export const {success, error, reset} = actions; | |
export default reducer; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment