Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

localstate-react

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

localstate-react

React HOC for Localstate

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

mvstate-react

A React HOC that make Mvstate and React a pleasure to use together

Mvstate can be a bit scary, at least if you are not familiar with functors. Mvstate-React provides you with a nice little HOC that allows you to express your React code more clearly. Let's look at an example:

// Model
export const create = () => ({counter: 1});
export const inc = ({counter}) => ({counter: counter + 1});
export const dec = ({counter}) => ({counter: counter - 1});

// Component
import {create, dec, inc} from './Model';

function Counter({refunc: {model, notify}}) {
    return (
        <div>
            <p>
                <strong>Counter is {model.counter}</strong>
            </p>
            <p>
                <button onClick={notify(dec)}>Decrement</button>
                <button onClick={notify(inc)}>Increment</button>
                <button onClick={notify(inc, dec, inc, dec)}>Silly button</button>
            </p>
        </div>
    );
}

export default observe(create(), Counter);

If you used Redux, you're probably already familiar with this pattern. "observe" will ensure that your component is updated every time notify is called.

Cheers, Peter Crona

FAQs

Package last updated on 04 Dec 2017

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