DEV Community

Discussion on: Best way to deal with immutable data in JS

Collapse
 
josemunoz profile image
José Muñoz

Since you mentioned Redux, there's an official abstraction that handles immutability for you in a very ergonomic way, it uses immer.js internally which is also another great immutability library.

GitHub logo reduxjs / redux-toolkit

The official, opinionated, batteries-included toolset for efficient Redux development

Redux Toolkit

build status npm version npm downloads

The official, opinionated, batteries-included toolset for efficient Redux development

(Formerly known as "Redux Starter Kit")

Installation

Using Create React App

The recommended way to start new apps with React and Redux Toolkit is by using the official Redux+JS template for Create React App, which takes advantage of React Redux's integration with React components.

npx create-react-app my-app --template redux
Enter fullscreen mode Exit fullscreen mode

An Existing App

Redux Toolkit is available as a package on NPM for use with a module bundler or in a Node application:

# NPM
npm install @reduxjs/toolkit
# Yarn
yarn add @reduxjs/toolkit
Enter fullscreen mode Exit fullscreen mode

It is also available as a precompiled UMD package that defines a window.RTK global variable The UMD package can be used as a <script> tag directly.

Purpose

The Redux Toolkit package is intended to be the standard way to write Redux logic. It was originally created to help address three common concerns about Redux:

  • "Configuring a…

GitHub logo immerjs / immer

Create the next immutable state by mutating the current one

Immer

npm Build Status Coverage Status code style: prettier OpenCollective OpenCollective Gitpod Ready-to-Code

Create the next immutable state tree by simply modifying the current tree

Winner of the "Breakthrough of the year" React open source award and "Most impactful contribution" JavaScript open source award in 2019

Contribute using one-click online setup

You can use Gitpod (a free online VS Code like IDE) for contributing online. With a single click it will launch a workspace and automatically:

  • clone the immer repo.
  • install the dependencies.
  • run yarn run start.

so that you can start coding straight away.

Open in Gitpod

Documentation

The documentation of this package is hosted at immerjs.github.io/immer/

Support

Did Immer make a difference to your project? Join the open collective at opencollective.com/immer!

Release notes

github.com/immerjs/immer/releases




Collapse
 
vborodulin profile image
Slava Borodulin • Edited

Yes, immer is a great library and with redux you can do amazing things but in general, immer try to solve too many problems(patches, async usage). So immutable-helpers for me more intuitive and simple approach with single responsibility and zero threshold