Skip to content

베이스 토스트 만들기

김서진 edited this page Nov 24, 2021 · 3 revisions

https://github.com/boostcampwm-2021/web09-Duxcord/pull/308

import { ToastData } from '@customTypes/toast';
import { createSlice } from '@reduxjs/toolkit';

const initState = Array<ToastData>();

const { reducer: toastReducer, actions } = createSlice({
  name: 'toast',
  initialState: initState,
  reducers: {
    addToast: (state, { payload }) => [...state, payload],
    popToast: (state, { payload }) => state.filter((toast) => toast.id !== payload.id),
  },
});

export const { addToast, popToast } = actions;

export default toastReducer;
Clone this wiki locally