redux-source-connect
v1.1.0
Published
Connect React components to Redux states maintained by redux-source automatically
Downloads
17
Maintainers
Readme
redux-source-connect
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
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 byconnectSource
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 {
// ...