Socket
Socket
Sign inDemoInstall

reusable

Package Overview
Dependencies
3
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    reusable

[![Build Status](https://circleci.com/gh/reusablejs/reusable.svg?style=svg)](https://circleci.com/gh/reusablejs/reusable) [![npm version](https://badge.fury.io/js/reusable.svg)](https://badge.fury.io/js/reusable)


Version published
Weekly downloads
569
decreased by-25.13%
Maintainers
1
Install size
3.88 MB
Created
Weekly downloads
 

Readme

Source

Build Status npm version

Docs

https://reusablejs.github.io/reusable

tl;dr

Reusable is a state management library that uses hooks. It allows to transform your custom hooks to stores, that have a shared state and behavior.
Just wrap your custom hooks with createStore and you're good to go.

const useSomething = createStore(() => {
  //custom hook
});

const Comp1 = () => {
  const something = useSomething();
}

const Comp2 = () => {
  const something = useSomething(); // same something
}

const App = () => (
  <ReusableProvider> {/* no initialization code */}
    ...
  </ReusableProvider>
)

What about hooks+Context

Using plain context is not a best solution for state management, that led us to write this library:

  • When managing global state using Context in a large app, you will probably have many small, single-purpose providers. Soon enough you'll find a Provider wrapper hell.
  • When you order the providers vertically, you can’t dynamically choose to depend on each other without changing the order, which might break things.
  • Context doesn't support selectors, render bailout, or debouncing

Feedback / Contributing:

We would love your feedback / suggestions Please open an issue for discussion before submitting a PR Thanks

FAQs

Last updated on 09 Jun 2019

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc