0.1.0 • Published 6 years ago

flumpt-connect v0.1.0

Weekly downloads
16
License
MIT
Repository
github
Last release
6 years ago

flumpt-connect

Connect function for mizchi/flumpt

Build Status npm version

Installation

$ npm install --save flumpt-connect

Example

import React from 'react';
import connect from 'flumpt-connect';

const MyComponent = ({ count, increment }) => (
  <div>
    {count}
    <button onClick={increment}>increment</button>
  </div>
);

export default connect(
  ({ count }) => ({ count }),
  { increment: 'increment' }
)(MyComponent);

API

connect([mapStateToProps], [mapDispatchToProps])

Connects a React component to a Flumpt state. This function is referred to react-redux's same name.

Arguments

  • mapStateToProps(state): stateProps (Function): It specifies a function that accepts the state of flumpt and returns Object. The result is passed as a props to the Component. If null or undefined is passed, no props is passed from the state.

  • mapDispatchToProps(dispatch): dispatchProps (Object or Function):

    • Object case: Its key is used as a key of props, and the paired value is used as an event name for EventEmitter. The new component receives a props: the key is as it is, and the paired value is a function that calls the dispatch function with the specieifed event name.
    • Function case: The specified function accepts the dispatch function of flumpt and returns Object. The result is passed as a props to the new component.
    • Not spefied case: If null or undefined is passed, the dispatch function is passed to the new component as it is.

LICENSE

MIT

0.1.0

6 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago