HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
immerjs
immer
JavaScript2018–2025
immerjs / immer

immer

Create the next immutable state by mutating the current one

22Distinct people
28Mentions
1Explicit recommenders
29KGitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

Create the next immutable state by mutating the current one

GitHub

Where it is used

No documented product use was verified in the last source check.

What people are saying

Hi, I'm a Redux maintainer. I personally would recommend _against_ using Immutable.js, for a number of reasons [0]. Instead, I highly recommend the Immer library [1], which…

acemarke used a recommendation phrase. One indexed comment matches. This is a phrase match, not a verdict.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

Mentioned in the same Hacker News threads. That is not proof they are substitutes.

This week on Hacker News

Nov 8–Nov 15 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/15/2026, 12:03:30 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year28 dated mentions

Observed mentions: 2018-01-01 19:34:07 UTC to 2025-12-25 16:13:03 UTC.

02468102018-01-01 00:00:00 UTC to 2019-01-01 00:00:00 UTC (exclusive): 9 mentions; 3 submissions, 6 comments20182019-01-01 00:00:00 UTC to 2020-01-01 00:00:00 UTC (exclusive): 9 mentions; 0 submissions, 9 comments2020-01-01 00:00:00 UTC to 2021-01-01 00:00:00 UTC (exclusive): 4 mentions; 0 submissions, 4 comments2021-01-01 00:00:00 UTC to 2022-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments20212022-01-01 00:00:00 UTC to 2023-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2023-01-01 00:00:00 UTC to 2024-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments2024-01-01 00:00:00 UTC to 2025-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2025-01-01 00:00:00 UTC to 2026-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2025

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20182018-01-01 00:00:00 UTC2019-01-01 00:00:00 UTC936
20192019-01-01 00:00:00 UTC2020-01-01 00:00:00 UTC909
20202020-01-01 00:00:00 UTC2021-01-01 00:00:00 UTC404
20212021-01-01 00:00:00 UTC2022-01-01 00:00:00 UTC202
20222022-01-01 00:00:00 UTC2023-01-01 00:00:00 UTC101
20232023-01-01 00:00:00 UTC2024-01-01 00:00:00 UTC202
20242024-01-01 00:00:00 UTC2025-01-01 00:00:00 UTC000
20252025-01-01 00:00:00 UTC2026-01-01 00:00:00 UTC101

What Hacker News says

9 sources
acemarke·May 23, 2019Recommendation phrase
Hi, I'm a Redux maintainer. I personally would recommend _against_ using Immutable.js, for a number of reasons [0]. Instead, I highly recommend the Immer library [1], which lets you do immutable updates with "mutating" logic in callbacks. Even better, try out our new Redux Starter Kit package. It uses Immer internally to let you simplify immutable updates in your reducers [2]. [0] https://www.reddit.com/r/javascript/comments/4rcqpx/dan_abra... [1] https://github.com/immerjs/immer [2] https://redux-starter-kit.js.org/
In JavaScript Array.push is 945x faster than Array.concat
To properly embrace immutable.js and not have performance issues, you need to fully embrace it and it's API and use it as the basis for all of the models in your app. We did a half-baked approach which uses immutables in the data store (so we can leverage quick prop checks) but also convert those into normal JS objects in the business domain. This makes our use of it noticeably slow. Immer [0] is a much better alternative IMO.. you get all the benefits of immutability without having to use a radically different API than normal. And the performance is roughly the same as immutable. And using it with Redux is natural [1], removing the need to do a bunch of nested object copies [0] https://github.com/immerjs/immer [1] https://daveceddia.com/react-redux-immutability-guide/#easy-...
In Why I don't use React
React's default behavior is that when a component re-renders, React will render all of its children recursively, even if they are receiving the exact same props as before. In many cases, these re-renders return the same render output as the previous render, which means that no changes need to be made to the DOM. These renders are referred to as "wasted", because React went through the work to ask your component "what do you want the UI to look like?" and diffing the output, when nothing actually was going to change. The two key aspects of optimizing performance in a React app are: - Decide if the props and state for this component have meaningfully changed - Tell React to skip the rest of the rendering process for this component (and therefore skip the rest of this subtree as well) The standard approach for checking for changes is simple
Read the rest
reference checks: `prevProps.a === props.a`. For larger amounts of data, this assumes you've updated that data "immutably", by making copies and modifying the copies instead of the originals. This can be done with plain JS objects and arrays, it just can take a bit more diligence. (Libraries like Immer [0] can help with applying those updates immutably.) For the "skip rendering" part, React has offered several APIs over time, but they all basically boil down to "do shallow comparisons of data, and bail out if they're the same": - The old / deprecated `createClass()` API allowed use of a `PureRenderMixin` - Classes have a `shouldComponentUpdate()` lifecycle method where you can implement whatever custom comparison logic you want, and return `false` if the render should be skipped - Since the typical comparison in `shouldComponentUpdate` is a shallow equality check of both props and state, the `PureComponent` base class was added that does that by default - More recently, the `React.memo(MyComponent)` API was added to allow wrapping any component (class or function) with that same bailout behavior. All of those are actual React APIs, not separate packages. All that said, the React team advises that you should just write the app first, _then_ profile it later (in a production build!) to see where the key bottlenecks are and just optimize those. In most cases, you probably don't even have to do anything - performance will often be sufficient as-is. React's DevTools have a performance profiling tab [1] [2] that helps show which components rendered for a given update, which makes it a lot easier to track down unnecessary renders. The community has also created various "why did you update?" libs that log unnecessary renders. [0] https://github.com/mweststrate/immer [1] https://reactjs.org/blog/2018/09/10/introducing-the-react-pr... [2] https://www.netlify.com/blog/2018/08/29/using-the-react-devt...
In Svelte 3: Rethinking Reactivity
Immer.js (a library to work on data structures, not a framework) uses a similar concept, using Proxies. The gist of Immer is that your framework needs immutable structures, but you want to interact with them imperatively. It's very interesting, and a reversal of the traditional "functional core, imperative shell" architecture. https://github.com/immerjs/immer
In Svelte 3: Rethinking Reactivity
Having experimented with and used proxies a decent amount, the MDN page is my goto reference when I need to use them: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... The biggest pitfalls, in my experience are 1. Infinite recursion when implementing get and printing proxies with console.log in node.js (which attempts to access properties from the object prototype which can lead to infinite recursion problems). 2. Performance, which I would need to do more digging and benchmarking to comment on in more depth. Some libraries that use Proxies to great effect are the https://github.com/mobxjs/mobx-state-tree and https://github.com/mweststrate/immer libraries both by mweststrate
In Meta Programming in JavaScript with Proxies
Here's a couple specific examples I just saw within the last couple days. `immer` is an immutable update library based on ES6 proxies. In addition to safely applying "mutative" code immutably, it also freezes the output to keep you from accidentally mutating it elsewhere. An Immer maintainer just added some kind of a `DeepReadOnly` tag to its typings in a patch release, which broke things for a bunch of people: https://github.com/mweststrate/immer/issues/289 This specifically broke our PR to convert `redux-starter-kit` to TS, with this lovely error message: https://github.com/reduxjs/redux-starter-kit/pull/73#issueco... I'm not saying every use of TS is that complex, but I do absolutely think that TS types can get ridiculously complex (and that people can get sucked into spending _way_ too much time trying to model dynamic JS behavior in
Read the rest
static types).
In Porting 30K lines of code from Flow to TypeScript

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.