1.0.6 • Published 6 years ago

react-redux-autoconnect v1.0.6

Weekly downloads
5
License
MIT
Repository
github
Last release
6 years ago

react-redux-autoconnect

Convention over configuration for react-redux's connect()

Travis npm

Usage

autoConnect(Component, [options])

Like connect(), but looks for static methods called mapStateToProps, mapDispatchToProps, and mergeProps on the passed Component, instead of passing them manually.

For how to use mapStateToProps, mapDispatchToProps, and mergeProps, read the react-redux documentation

The optional options argument is also passed to connect() as the fourth argument.

Why?

So you can now keep everything wrapped up in a single class:

import autoConnect from 'react-redux-autoconnect'

class Foo extends React.Compoment {
  render () {
    return (
      <div>Hello {this.props.name}!</div>
    )
  }

  static mapStateToProps = (state) => ({
    name: state.name
  })
}

export default autoConnect(Foo)

This is stupidly simple code and you should be ashamed

I know, but I was fed up of writing the same utility function over and over.

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago