Disconnect mapDispatchToProps

Disconnects mapDispatchToProps from a component connected to a redux store. Disconnects completely if possible.

How it works

  • Removes mapDispatchToProps definition (if present)
  • If connect is present and no non-null parameters other than mapDispatchToProps are passed to it
    • Unwraps exported (returned, if it's a HOC) component from connect
    • Removes connect import statement
  • If connect is present and mergeProps is passed to it
    • Replaces mapDispatchToProps parameter with null in connect call (if present)
  • If connect is present and mergeProps is not passed to it
    • Removes mapDispatchToProps parameter from connect call (if 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

Packages

  • react
  • react-redux

Examples

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