JSPM

react-redux-connect-lifecycle

1.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q30693F
  • License ISC

A higher-order component to connect a React component to a redux store with component 'mount' lifecycle events

Package Exports

  • react-redux-connect-lifecycle

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-redux-connect-lifecycle) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

react-redux-connect-lifecycle

A higher-order component to connect a React component to a redux store with component 'mount' lifecycle events.

Usage

In a container, connect() is used just like connect() from 'react-redux'. The difference is lifecycle events will be added to the component and can be dispatched as actions.

Each lifecycle event has the component's 'props' passed as the only argument.

// MyComponentContainer.js
import connect from 'react-redux-connect-lifecycle'
import MyComponent from './MyComponent'

const mapStateToProps = state => ({
  /* ... */
})

const mapDispatchToProps = ({
  /* ... */
  onComponentWillMount  : (props) => ({ type: 'WILL_MOUNT'  , props }),
  onComponentDidMount   : (props) => ({ type: 'DID_MOUNT'   , props }),
  onComponentDidUpdate  : (props) => ({ type: 'DID_UPDATE'  , props }),
  onComponentWillUnmount: (props) => ({ type: 'WILL_UNMOUNT', props })
})

export default connect(mapStateToProps,mapDispatchToProps)(MyComponent)