Code Monkey home page Code Monkey logo

delux-react's Introduction

Delux-React

Delux bindings for React

import Store, {Collection} from 'delux';
import React from 'react';
import {ConnectedComponent} from 'delux-react';

class myComponent extends ConnectedComponent {
  static get collections () {
      return ['images'];
  }
  render () {
    return <div>{JSON.stringify(this.state.images)}</div>;
  }
}

let store = new Store ();

store.images = new Collection({});

<Provider store={store}>
  {connect(myComponent, ['images'])}
</Provider>

Features

API Reference

Provider

Provider wraps connected components to the store.

Create a Provider
<Provider store={store}></Provider>
Description

The Provider is a React component which pass your store to it's child component through context.

Props
  • store - Delux store to provide to the child component

ConnectedComponent

Creates React Components connected to the store.

Create a connected component
// ES6

class MyComponent extends ConnectedComponent {
    //...
}

MyComponent.collections = collectionNames;

// ES6 static getter

class MyComponent extends ConnectedComponent {
    static get collections () {
        return collectionNames;
    }
    //...
}

// ESNext

class MyComponent extends ConnectedComponent {
    static collections = collectionNames;
    //...
}
Parameters
  • collectionNames - Store collections the component uses.
ConnectedComponent Instance
State

The state of the component is unified with the state of the selected collections.

Methods

dispatch()

Store#dispatch alias

Testing

in /delux-react:

 $ npm test

open /test/test.html with a modern browser.

delux-react's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.