Reincarnation of an old package
In 2020, react-relink
was released. It was heavily inspired by recoil
and had a similar API design.
react-relink
was created with the goals of:
- not needing to wrap components in Providers while still allowing states to be shared across different React components trees, and
- make it easy to transition from
recoil
by introducing similar concepts and APIs.
As time goes on, the concepts of recoil
were slowly disregarded, new features were added, and react-relink
began to evolve into a state management library of it's own.
At that point, there were three main problems...
- The codebase became bloated and difficult to maintain
- It became so slow, that in some scenarios, it results in very noticeable lagging
- There was no easy way to use
react-relink
as a state management tool outside of React because the dependencies are tied together.
Eventually, the better solution was to create a new package two new packages —
a core package and another one for its React bindings. This allows non-React projects to use this new state management library without needing to install react
as a dependency, and the core package is called cotton-box
.
cotton-box
exposes three different types of State Managers that are built on top of one another for different needs:
SimpleStateManager
— the most lightweight state managerStateManager
- generic state manager with lifecycle hooks for persisting dataAsyncStateManager
- similar toStateManager
but supports async set-state functions
More information on the differences between these State Managers are available here.
If you're migrating from react-relink
, it is highly recommended to check out the migration guide.