# simple-redux-connect

> '对react-redux中connect的封装，使其更方便使用'

Latest version **1.0.5** (published 2018-11-28) · ISC license · 0 weekly downloads

## Install

```sh
npm install simple-redux-connect
pnpm add simple-redux-connect
yarn add simple-redux-connect
bun add simple-redux-connect
```

## 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.5 |
| Published | 2018-11-28 |
| First published | 2018-11-27 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 4.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | miaojiang |
| Maintainers | miaojiang |
| Keywords | react-redux, redux, connect, react |

## Links

- npm: https://www.npmjs.com/package/simple-redux-connect
- npm.io page: https://npm.io/package/simple-redux-connect

## Dependencies (2)

- [redux](https://npm.io/package/redux.md) ^4.0.1
- [react-redux](https://npm.io/package/react-redux.md) ^5.1.1

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.5 (latest) — 2018-11-28
- 1.0.4 — 2018-11-28
- 1.0.3 — 2018-11-28
- 1.0.2 — 2018-11-28
- 1.0.1 — 2018-11-28
- 1.0.0 — 2018-11-27

## README

simple-redux-connect
=======
对react-redux中的connect进行封装，使其避免多次写mapStateToProps，mapDispatchToProps之类的重复的逻辑；并且，可以按需引入我们需要用到的store中的内容，这里举例用的是main。该模块已经集成react-redux中的connect，不必单独下载。
 

## Install

```bash
$ npm install simple-redux-connect
```

## Usage
 
before（之前我们这样做）
```js
//需要Provider时，这样引入 
import { Provider } from 'react-redux'
//引入connect和actionCreators
import { connect } from 'react-redux'
import actionCreators from '../../store/home/actionCreators' 

const mapStateToProps = (state) => {
  return {//返回需要的模块(这里是store中的main)中的属性
    list: state.main.list

  }
}

const mapDispatchToProps = (dispatch) => {
  return {//返回actionCreators方法

    getSwiperListAsync() {
          dispatch(actionCreators.getSwiperListAsync())
      }
  }
} 
export default connect(mapStateToProps, mapDispatchToProps)(UIcomponent)
 
```
now,we can（现在，我们这样做，是不是方便很多呢）bingo！
```js
//需要Provider时，这样引入
import { Provider } from 'simple-redux-connect'
//引入我们封装的connect模块
import { connect } from 'simple-redux-connect'

//传入我们需要的模块，这里是(main)
export default connect(UIcomponent, [{name: 'main', state: ['list']}])//main:your store,list:your state
```
or
```js
//需要Provider时，这样引入
import { Provider } from 'simple-redux-connect'
//引入我们封装的connect模块
import  { connect } from 'simple-redux-connect'

//传入我们需要的模块，这里是(main)
export default connect(UIcomponent, [ 'main'])//main:your store
```

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