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

dob-react

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dob-react

React bindings for dob.

  • 2.4.17
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
decreased by-84.62%
Maintainers
1
Weekly downloads
 
Created
Source

dob-react · CircleCI Status npm version code coverage

React bindings for dob.

Design idea from Mobx Implementation

Install

npm i dob-react

Online demo

Here is a basic demo, and here is a demo with fractal.

Simple Usage

import { Provider, Connect } from 'dob-react'

@Connect
class App extends React.Component <any, any> {
    render() {
        return (
            <span>{this.props.store.name}</span>
        )
    }
}

ReactDOM.render(
    <Provider store={{ name: 'bob' }}>
        <App />
    </Provider>
, document.getElementById('react-dom'))

Connect: All parameters from outer Provider are injected into the wrapped components, and the component rerender when the variables used in the render function are modified(sync usage).

Connect all functions

Connect all

Connect all from Provider's parameters, also is this example above.

Connect extra data

Will also inject all parameters from outer Provider.

@Connect({
    customStore: {
        name: 'lucy'
    }
})
class App extends React.Component <any, any> {}

Map state to props

Will also inject all parameters from outer Provider.

@Connect(state => {
    return {
        customName: 'custom' + state.store.name
    }
})
class App extends React.Component <any, any> {}

ReactDOM.render(
    <Provider store={{ name: 'bob' }}> <App /> </Provider>
, document.getElementById('react-dom'))

Support stateless component

class App extends React.Component <any, any> {
    render() {
        return (
            <span>{this.props.store.name}</span>
        )
    }
}

const ConnectApp = Connect()(App)
// const ConnectApp = Connect({ ... })(App)
// const ConnectApp = Connect( state => { ... })(App)

FAQs

Package last updated on 28 Feb 2019

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