ucho / flumpt-connect

Connect function for mizchi/flumpt

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

Connect function for mizchi/flumpt

License:MIT License


Languages

Language:JavaScript 100.0%