Connect

Connects a component to the redux store with both mapStateToProps & mapDispatchToProps generated.

How it works

  • Defines mapStateToProps below the component definition (if not present)
  • Defines mapDispatchToProps below the component definition (if not present)
  • Wraps exported (returned, if it's a HOC) component with connect (if not present)
  • Uses mapStateToProps & mapDispatchToProps with aforementioned connect (replacing null values if present)
  • Adds connect import statement (if not present)

Works with

  • Functional components defined as an arrow function
  • Functional components defined as a function
  • Class components
  • Higher order functional components defined as an arrow function
  • Higher order functional components defined as a function
  • Higher order class components

Examples

© 2018 - 2019 Kamil Mielnik & Yuriy Yakym. All rights reserved.