# hoc-redux-connector

> A React High-Order Component to simplify the usage of mapStateToProps and mapDispatchToProps of react-redux

Latest version **1.0.0** (published 2018-10-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install hoc-redux-connector
pnpm add hoc-redux-connector
yarn add hoc-redux-connector
bun add hoc-redux-connector
```

## 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.0 |
| Published | 2018-10-23 |
| First published | 2018-02-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 800.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | llccrr |
| Maintainers | llccrr |
| Keywords | redux, react, hoc, High Order Component, react-redux, redux-connector, hoc-redux-connector |

## Links

- npm: https://www.npmjs.com/package/hoc-redux-connector
- Issues: https://github.com/llccrr/hoc-connect-to-redux/issues
- npm.io page: https://npm.io/package/hoc-redux-connector

## Dependencies (5)

- [react](https://npm.io/package/react.md) ^16.2.0
- [redux](https://npm.io/package/redux.md) ^3.7.2
- [lodash](https://npm.io/package/lodash.md) ^4.17.5
- [webpack](https://npm.io/package/webpack.md) ^3.11.0
- [react-redux](https://npm.io/package/react-redux.md) ^5.0.7

## 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.0 (latest) — 2018-10-23
- 0.1.1 — 2018-02-28
- 0.1.0 — 2018-02-26
- 0.0.1 — 2018-02-26

## README

## Usage
```
yarn add hoc-redux-connector
```
```
npm install --save hoc-redux-connector
```

To subscribe the component to the store you can use it this way :
```js
import { connectToRedux } from 'hoc-redux-connector';

// Here a Basic React component
const PureDisplayer = ({ myDeeperText, ...props }) => (
    <ul>
        <li>{props.myText}</li>
        <li>{myDeeperText}</li>
    </ul>
);

export const Displayer = connectToRedux({
  myText: 'reducerName.text',
  myDeeperText: 'reducerName.deeperText.text'
})(PureDisplayer);
// Once connected, you can access to myText and myDeeperText from your component props
```
To connect actions to a component you can use it this way :
```js
import { myAction, mySecondAction } from 'path_to_your_actions';

const PureDispatcher = (props) => (
    <Button onClick={(string) => props.newActionName(string)}/>
);

export const Dispatcher = connectToRedux(null, {
  myAction, //ES6 Syntax, the action will be available in the props of the component from this.props.myAction()
  newActionName: mySecondAction // Here the dispatched action mySecondAction will be available from this.props.newActionName()
})(PureDispatcher);
// Note that each function inside the object is assumed to be a Redux action creator
```

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