└── alert.js /alert.js: -------------------------------------------------------------------------------- 1 | import { v4 as uuidv4 } from 'uuid'; 2 | import { SET_ALERT, REMOVE_ALERT } from './types'; 3 | 4 | export const setAlert = (msg, alertType, timeout = 3000) => (dispatch) => { 5 | const id = uuidv4(); 6 | dispatch({ 7 | type: SET_ALERT, 8 | payload: { msg, alertType, id }, 9 | }); 10 | 11 | setTimeout(() => dispatch({ type: REMOVE_ALERT, payload: id }), timeout); 12 | }; 13 | --------------------------------------------------------------------------------