Download spectrum/src/reducers/toasts.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 581 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/src/reducers/toasts.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/spectrum/src/reducers/toasts.js
-
curl -L -o toasts.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/src/reducers/toasts.js
581 Bytes
| const initialState = { | |
| toasts: [], | |
| }; | |
| /* | |
| Payload shape: | |
| payload: { | |
| kind: 'error' | 'success', | |
| message: string | |
| } | |
| */ | |
| export default function toasts(state = initialState, action) { | |
| switch (action.type) { | |
| case 'ADD_TOAST': { | |
| return Object.assign({}, state, { | |
| toasts: [...state.toasts, action.payload], | |
| }); | |
| } | |
| case 'REMOVE_TOAST': { | |
| const toasts = state.toasts.filter(toast => { | |
| return toast.id !== action.id; | |
| }); | |
| return Object.assign({}, state, { | |
| toasts, | |
| }); | |
| } | |
| default: | |
| return state; | |
| } | |
| } | |