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

djinn-state-react

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

djinn-state-react

djinn-state helpers for react

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-40%
Maintainers
1
Weekly downloads
 
Created
Source

Djinn-state react

Build Status Codacy Badge Codacy Badge

Djinn-state helpers for react

Install

npm npm i --save djinn-state djinn-state-react

yarn yarn add djinn-state djinn-state-react

Using

// djinn.js
import { Djinn, DjinnService } from 'djinn-state';
import { createDjinnConnector } from 'djinn-state-react';

export const djinn = new Djinn();
export const connect = createDjinnConnector(djinn);


// CounterService.js
export class CounterService extends DjinnService {
  state = {
    count: 0,
  };
  
  decrement = () => {
    const count = this.state.count - 1;
    this.patch({ count });
  };
  
  increment = () => {
    const count = this.state.count + 1;
    this.patch({ count });
  };
}

// djinnServices.js
import { djinn } from './djinn';

djinn.register(CounterService);
djinn.start();


// HomePage.js
import React from 'react';
import { connect } from './djinn';
import { CounterService } from './CounterService';

const HomePage = ({ services, state }) => (
  <div>
    <button onClick={services.CounterService.decrement}>-</button>
    {state.CounterService.count}
    <button onClick={services.CounterService.increment}>+</button>
  </div>
);

export default connect({
  CounterService,
})(HomePage);

Keywords

FAQs

Package last updated on 26 Dec 2018

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