State
State
Overview
A package for working with React state in a more ergonomic way.
Installation
Required dependencies
This package relies on React hooks and thus requires version 16.3 or higher.
# npm
npm i --save @weser/state
# yarn
yarn add @weser/state
# pnpm
pnpm add @weser/state
Motivation
There are many ways to handle state in React, including the built-in useState, useReducer or the fairly new useOptimistic.
The first two are great, but lack first-class support for side effects (unless you use useEffect, which has its very own set of problems) while the latter doesn't really have the most ergonomic API.
That's why I decided to create this package to provide a more ergonomic, low-level API for state management.
Benefits
This package provides a more ergonomic, low-level API for state management including reducers with side effects and a useState-like hook with optimistic updates.
© 2024-present Robin Weser. All Rights Reserved.