2.0.0 • Published 9 years ago

react-fluxury v2.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
9 years ago

react-fluxury

Circle CI

Bind fluxury stores to React.js.

quick start

npm install --save react-fluxury
import {createClass, connectStore} from 'react-fluxury'

connect

Returns a function that generates a React component that runs your render function.

connect(store, transform)(renderFunc)

import {createStore} from 'fluxury'
import {createClass} from 'react-fluxury'

var CounterStore = createStore({
  getInitialState: () => ({ count: 0 }),
  increment: (state) => ({ count: state.count + 1 }),
});

var CounterView = createClass(
  CounterStore,
)(({count}) => (
  <div>{count}</div>
))

higher-order component

Higher order functions are so cool and are compatible with ES6 classes.

In this case state is passed down as props to the wrapped component.

var Component = require('react').Component;
var {createStore, dispatch} = require('fluxury');
var {connectStore} = require('react-fluxury');

class MyComponent extends Component {

  handleUpClick() {
    dispatch('increment')
  }

  handleDownClick() {
    dispatch('decrement')
  }

  render() {
    return (
      <div>
        <p>{this.props.count}</p>
        <button onClick={this.handleUpClick}>+1</button>
        <button onClick={this.handleDownClick}>-1</button>
      </div>
    );
  }

});

EnhancedComponent = connectStore(countStore, MyComponent, (state) => {
  count: state
})
2.0.0

9 years ago

1.3.0

9 years ago

0.2.0

9 years ago

0.1.8

10 years ago

0.1.7

10 years ago

0.1.6

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.1

10 years ago