renamed
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { createSlice } from "@reduxjs/toolkit";
|
||||
|
||||
const notificationSlice = createSlice({
|
||||
name: "notification",
|
||||
initialState: [],
|
||||
reducers: {
|
||||
make(state, action, time) {
|
||||
state.push(action.payload);
|
||||
},
|
||||
remove(state, action) {
|
||||
state.pop();
|
||||
},
|
||||
},
|
||||
});
|
||||
const { make, remove} = notificationSlice.actions;
|
||||
export const setNotification = (message,time) => {
|
||||
return (dispatch) => {
|
||||
dispatch(make(message));
|
||||
setTimeout(() => dispatch(remove()), time * 1000);
|
||||
};
|
||||
};
|
||||
|
||||
export default notificationSlice.reducer;
|
||||
Reference in New Issue
Block a user