Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-redux-connect

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-redux-connect

Connect react components to redux store using component static props

  • 0.1.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
13
increased by550%
Maintainers
1
Weekly downloads
 
Created
Source

Installation

yarn add react-redux-connect

Usage

Store all connect options as a static attributes inside your component.

import connect from 'react-redux-connect';
import { actionOne, actionTwo }  from './actions';

export class MySmartComponent {
    static mapStateToProps(state, ownProps) {
        // if you need to map some data from store
        return {
            // some data from state here
        };
    }
    
    static mapDispatchToProps(dispatch, ownProps) {
        // if you need to dispatch some actions
        return {
            actionOne,
            actionTwo,
        };
    }
    
    static mergeProps(stateProps, dispatchProps, ownProps) {
        // if you want to merge props manually
        return {
            // ...
        }
    }
    
    static connectOptions = {
        // if you need to tweek some connect options
        // e.g. pure: false
    };
    
    render() {
        // return something...
    }
}

// and just pass your component to `connect` function
// all settings will be taken from static props
export default connect(MySmartComponent);

Example below is the same to following:

import { connect } from 'react-redux';
import { actionOne, actionTwo }  from './actions';


const mapStateToProps = (state, ownProps) => {
    // if you need to map some data from store
    return {
        // some data from state here
    };
};

const mapDispatchToProps = (dispatch, ownProps) => {
    // if you need to dispatch some actions
    return {
        actionOne,
        actionTwo,
    };
};
    
const mergeProps = (stateProps, dispatchProps, ownProps) => {
    // if you want to merge props manually
    return {
        // ...
    }
};
    
const connectOptions = {
    // if you need to tweek some connect options
    // e.g. pure: false
};

export class MySmartComponent {
    render() {
        // return something...
    }
}

export default connect(mapStateToProps, mapDispatchToProps, mergeProps, connectOptions)(MySmartComponent);

Licence

MIT

Testing

yarn test

Contributing

You are welcome! :)

FAQs

Package last updated on 27 Jan 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc