Skip to main content

drawReducer

Applies an action to the drawing. Pure: an action that changes nothing returns the same state object, so React can skip re-rendering. Shapes are named in English; see createDrawReducer for another language.

This is a function exported by @mapcairn/core, checked against version 0.2.0.

Signature​

import { drawReducer } from "@mapcairn/core";

drawReducer: (state: DrawState, action: DrawAction) => DrawState

Parameters​

  • state (DrawState)
  • action (DrawAction)

Returns​

DrawState

Remarks​

Every edit goes on the undo stack as the shapes and selection before it (at most DRAW_HISTORY_LIMIT steps), except an edit that passes the same coalesceKey as the one just before it, which joins that step. Selecting, stepping and changing mode with nothing drawn are not edits. A refused action leaves the shapes alone and sets a rejected event naming why.

See also​

Source: packages/core/src/draw/reducer.ts:777