DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Or Yoffe
Or Yoffe

Posted on • Updated on

A simple, small JavaScript state library called jstates πŸ“‘πŸ›°οΈ

TL;DR
jstates: the core state library https://www.npmjs.com/package/jstates jstates-react: A Reactjs subscribe function for jstates https://www.npmjs.com/package/jstates-react

A simple (one file ☝️), small (less than 800B πŸ™‰), extendable ♻️, and most of all πŸ‘€ understandable, JavaScript state library and in addition a Reactjs❀️ subscribe function to use as a HOC (Higher Order Component) without context complications.

Why another state library? πŸ˜’
There are many great state libraries for react and JavaScript in general (for example: redux, mobx, unstated and more…). So why create another one? 😏

I wanted to have the simplest, most clear and usable solution I could think of. I wanted to have a few features in a state library that I didn’t find together in one library:

  1. Tiny bundle size (so I don’t have to think twice before installing)
  2. Small code base (one file: index.js)
  3. Simple and understandable (so other developers could start with it quickly and even improve it)
  4. Extendable (so I can add the functionality I need and others could too) Can have multiple separated states
  5. The best api parts of the state libraries I used (IMO, feel free to copy and create your own or maybe create a Pull request πŸ˜‰)
  6. Whatever else others want and need that they can’t find out there…

State can be simple and there is no reason why there shouldn’t be many of them out there for many use cases and for the developers around us with different (some might say β€œstrange” 😝) flavors.

When I started with Reactjs 😍, before even playing for a while with react, I was told to use redux and to learn it straight away πŸ˜“.
Redux (β€œThe King” πŸ‘‘ as some might call it) is a great library πŸ‘, but I had a hard time with it and a harder time throughout my career explaining it to people 😣.
In addition, explaining the state issue and the components communication in Reactjs and why we need an additional state instead of global objects is complicated enough πŸ˜•. I don’t think we need another additional concept to learn on the way (again, IMO πŸ˜…).

So without further delay πŸ“£, I would like to present to you…

Jstates, a simple and easy to use state library that would work with any js library or framework πŸŽ‰

And if you want to use it with Reactjs, it fits without any in the root of your app since it’s separated from the components context πŸ˜ƒ

Happy hacking πŸ‘· and thank open source people for giving their time to create the great tools I learned from πŸ™

Top comments (0)

16 Libraries You Should Know as a React Developer

Being a modern React developer is not about knowing just React itself. To stay competitive, it is highly recommended to explore the whole ecosystem. This article contains some of the most useful React component libraries to speed up your developer workflow.