Introducing Immer: Immutability the easy wayby@mweststrate
47,838 reads

Introducing Immer: Immutability the easy way

tldt arrow
Read on Terminal Reader
Read this story w/o Javascript

Too Long; Didn't Read

Immutable data structures are a great paradigm for storing state. But in a language like JavaScript, producing a new state from the previous one is a boring, boiler-platy task. Introducing Immer: Immutability the easy way to use persistent data structures in ReactJS. Immer works by writing producers, and the simplest producer possible looks like this: const nextState = produce(currentState, draft) The next state is simply the state we started with. All changes to draft are reflected in the next state, which structurally shares untouched items.

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - Introducing Immer: Immutability the easy way
Michel Weststrate HackerNoon profile picture

@mweststrate

Michel Weststrate

Receive Stories from @mweststrate

react to story with heart

RELATED STORIES

L O A D I N G
. . . comments & more!