# react-redux-autoconnect

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

Latest version **1.0.6** (published 2018-01-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-redux-autoconnect
pnpm add react-redux-autoconnect
yarn add react-redux-autoconnect
bun add react-redux-autoconnect
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2018-01-25 |
| First published | 2017-06-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Robert Sargant |
| Maintainers | sargant |

## Links

- npm: https://www.npmjs.com/package/react-redux-autoconnect
- Repository: https://github.com/sargant/react-redux-autoconnect
- npm.io page: https://npm.io/package/react-redux-autoconnect

## Recent versions

- 1.0.6 (latest) — 2018-01-25
- 1.0.5 — 2018-01-25
- 1.0.4 — 2017-06-02

## README

# react-redux-autoconnect

Convention over configuration for [react-redux](https://github.com/reactjs/react-redux)'s `connect()`

[![Travis](https://img.shields.io/travis/sargant/react-redux-autoconnect.svg?style=flat-square)](https://travis-ci.org/sargant/react-redux-autoconnect)
[![npm](https://img.shields.io/npm/v/react-redux-autoconnect.svg?style=flat-square)](https://www.npmjs.com/package/react-redux-autoconnect)

## Usage

```javascript
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](https://github.com/reactjs/react-redux/blob/master/docs/api.md#connectmapstatetoprops-mapdispatchtoprops-mergeprops-options)

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:

```javascript
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.

---
_Source: https://npm.io/package/react-redux-autoconnect · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
