redux-source-connect

1.1.0 • Public • Published

redux-source-connect

< Back to Project WebCube

NPM Version

Nodei

Connect React components to Redux states maintained by redux-source automatically

npm install --save redux-source-connect

For Immutable.js store: redux-source-connect-immutable

Get Started

For redux-source's example:

import { connect } from 'react-redux';
import connectSource from 'redux-source-connect';
import { shopsSource } from '../ducks/shops';
 
@connectSource(shopsSource, {
  slice: state => state.shops,
  actionsProp: 'actions', // optional
  enableErrorLogger: false, // optional
})
@connect(
  //...
)
export default class ShopList extends PureComponent {
  render() {
    const {
      source: {
        result: { shops },
        errors,
        isPending,
      },
      actions,
    } = this.props;
// ...

TIPS

  • this.props.source.result is automatically denormalized by connectSource

or with redux-cube's connect:

import { connect } from 'redux-cube';
import connectSource from 'redux-source-connect';
import { actions, shopsSource } from '../ducks/shops';
 
@connectSource(shopsSource, {
  slice: state => state.shops,
})
@connect({
  // ...
  actions,
})
export default class ShopList extends PureComponent {
// ...

Package Sidebar

Install

npm i redux-source-connect

Weekly Downloads

0

Version

1.1.0

License

MIT

Unpacked Size

11.2 kB

Total Files

10

Last publish

Collaborators

  • dexteryy