use-immer
xstate
use-immer | xstate | |
---|---|---|
8 | 60 | |
3,731 | 26,155 | |
1.6% | 0.6% | |
3.6 | 9.6 | |
7 months ago | 6 days ago | |
TypeScript | TypeScript | |
MIT License | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
use-immer
-
A cure for React useState hell?
The use-immer package additionally provides a useImmerReducer ****function that allows you to make state transitions via direct mutation, but under the hood creates an immutable copy using Proxies in JavaScript.
-
Zustand vs Jotai vs Valtio? Which state management library do you prefer created by the same team?
Apply useImmer to the top component state and the dream is complete.
-
Copying the contents of an existing array to a new array
If you want to use mutating code while ensuring that the final update is immutable, I recommend checking out useImmer (and useImmerReducer) - it uses immer to track mutations and do them immutably for you.
-
Handling Objects in React Component State
If you find yourself using multiple objects or in your state, it may be worth it to install a library like immer. Immer provides a proxy object, referred to as a draft, so while your code appears similar to a direct mutation of state, a copy is created under the hood when an update when immer is used.
-
Writing useState for each state variable or writing usestate once and use an object
useImmer is also pretty nice too - useReducer is definitely the way if you only want specific ways to manipulate the object though (and useImmerReducer can make writing the logic for that easier too)
-
How to update state of type object array with setstate hook?
Within the component itself, I used a useImmer hook for the state, as it lets me write mutating code while ensuring that the actual update is immutable - but if you're only holding your array in the useState hook, a shallow clone would work fine. js setItems(items => arrayMove([...items], ...params))
-
Electron Adventures: Episode 54: Notebook state management with useImmer
React is a lot more strict, and for what we need we cannot leave the state in individual components, we need to pull it up to the App component. Making modifications to deeply nested state is a lot of nasty code, fortunately React world has a solution - immer and its hooks version useImmer.
- How to handle Immutability in React? (Immer Library to rescue)
xstate
-
Mastering XState Fundamentals: A React-powered Guide
XState is a powerful library with comprehensive documentation. Keeping the documentation handy while building your next app with XState will be invaluable.
- 5 Alternatives to Redux for React State Management
-
Unleashing the Power of Actors in Frontend Application Development
XState is an excellent library that simplifies the utilization of actors in JavaScript applications. While this article focuses on using React, these principles apply equally well to other frameworks. In fact, they can be implemented anywhere JavaScript is executed.
-
Rethinking State Management - Why XState is a Game-Changer for Developers
In this article, I want to share a personal journey of discovery in the world of state management. My path led me to XState, a tool that I believe is the best choice for managing state in modern applications like React, Angular, Vue, and others. This isn't just a professional advice; it's a personal recommendation based on real-world experience.
-
Get out of state management hell with automatic revalidation
You add the current user state to a React Context or state management library, read from it on the top bar, and write to it after a user signs in. Done. No big deal, right?
- Como encontrar tema de tcc em ciência da computação?
- Sequence diagrams, the only good thing UML brought to software development
-
Scalability: the Lost Level of React State Management
Lastly, I know that I've omitted many great tools like XState, React Query, and SWR. These tools are utilities that are very scalable in their own right, but aren't full replacements for a good state manager.
- JavaScript State Machines and Statecharts
What are some alternatives?
Immer - Create the next immutable state by mutating the current one
redux - A JS library for predictable global state management
MobX - Simple, scalable state management.
jssm - Fast, easy Javascript finite state machines with visualizations; enjoy a one liner FSM instead of pages. MIT; Typescripted; 100% test coverage. Implements the FSL language.
zustand - 🐻 Bear necessities for state management in React
ringpop-go - Scalable, fault-tolerant application-layer sharding for Go applications
downshift 🏎 - 🏎 A set of primitives to build simple, flexible, WAI-ARIA compliant React autocomplete, combobox or select dropdown components.
awesome-workflow-engines - A curated list of awesome open source workflow engines
redux - Predictable state container for JavaScript apps [Moved to: https://github.com/reduxjs/redux]
jspython - JSPython is a python-like syntax interpreter implemented with javascript that runs entirely in the web browser and/or in the NodeJS environment.
Javascript State Machine - A javascript finite state machine library