UNPKG

@deepdub/react-arborist

Version:
20 lines (17 loc) 378 B
/* Types */ export type EditState = { id: string | null }; /* Actions */ export function edit(id: string | null) { return { type: "EDIT" as const, id }; } /* Reducer */ export function reducer( state: EditState = { id: null }, action: ReturnType<typeof edit> ) { if (action.type === "EDIT") { return { ...state, id: action.id }; } else { return state; } }