/
valslava
/
react-practice_project
Обзор
Документация
Войти
/
valslava
/
react-practice_project
Код
Запросы
0
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
hooks
src/context/alert/alertReducer.js
12 строк
331 B
valslava2
upgrade Alert comp using hooks
27 мар 2024, 00:47
27 мар 2024, 00:47
207e3be
Код
Авторство
О чём код?
import { HIDE_ALERT, SHOW_ALERT } from "../types"; const handlers = { [SHOW_ALERT]: (state, action) => action.payload, [HIDE_ALERT]: () => null, DEFAULT: state => state } export const alertReducer = (state, action) => { const handler = handlers[action.type] || handlers.DEFAULT return handler(state, action) }