/
githubmirror
/
gutenberg
Обзор
Документация
Войти
/
githubmirror
/
gutenberg
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
packages/boot/src/store/reducer.ts
47 строк
855 B
Marco Ciampini
ESLint: Replace strict config with bulk suppressions (#81248)
07 авг 2026, 14:34
Не верифицирован
07 авг 2026, 14:34
7f43eaf
Код
Авторство
О чём код?
import type { Action } from './actions'; import type { State } from './types'; const initialState: State = { menuItems: {}, routes: [], dashboardLink: undefined, }; export function reducer( state: State = initialState, action: Action ): State { switch ( action.type ) { case 'REGISTER_MENU_ITEM': return { ...state, menuItems: { ...state.menuItems, [ action.id ]: action.menuItem, }, }; case 'UPDATE_MENU_ITEM': return { ...state, menuItems: { ...state.menuItems, [ action.id ]: { ...state.menuItems[ action.id ], ...action.updates, }, }, }; case 'REGISTER_ROUTE': return { ...state, routes: [ ...state.routes, action.route ], }; case 'SET_DASHBOARD_LINK': return { ...state, dashboardLink: action.dashboardLink, }; } return state; }