Socket
Socket
Sign inDemoInstall

simpler-state

Package Overview
Dependencies
Maintainers
1
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simpler-state

The simplest app state management for React


Version published
Weekly downloads
60K
increased by1.66%
Maintainers
1
Weekly downloads
 
Created
Source

SimpleR State

npm build coverage license

SimpleR State is an ultra-lightweight library that provides the simplest state management for React.

  • No complicated concepts or boilerplate code
  • Just use plain functions to implement state changes
  • Largely unopinionated with flexible syntax
  • Extremely simple to unit test state changes
  • Full TypeScript support with uncomplicated types
  • Made specifically for React, and built on React Hooks
  • Multiple times faster than context/reducer solution
  • It's tiny, less than 1 KB (minified + gzipped)

Get all these benefits with one dependency install:

npm install simpler-state

Two Easy Steps!

Step 1: Create an entity (shared state) and actions (updater functions)

// counter.js

import { entity } from 'simpler-state'

export const counter = entity(0)

export const increment = by => {
  counter.set(counter.get() + by)
}

export const decrement = by => {
  counter.set(counter.get() - by)
}

Step 2: Use the entity in your components with hooks

import { useEntity } from 'simpler-state'
import { counter, increment, decrement } from 'counter'

const CounterView = () => {
  const count = useEntity(counter)

  return (
    <>
      <div>{count}</div>

      <button onClick={() => increment(1)}> + </button> 
      <button onClick={() => decrement(1)}> - </button>
    </>
  )
}

It's that simple!

Documentation

Learn more about SimpleR State at simpler-state.js.org.

Feedback

I have opened a Request For Comments (here) on GitHub. Your comments and suggestions would be greatly appreciated.

And if you like this library, the concept, and its simplicity, please give it a star on GitHub to let me know. 😀

Keywords

FAQs

Package last updated on 12 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc