# hoc-with-store

> Higher-order React component for binding a Redux Store

Latest version **0.1.0** (published 2018-06-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install hoc-with-store
pnpm add hoc-with-store
yarn add hoc-with-store
bun add hoc-with-store
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2018-06-09 |
| First published | 2018-06-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 62.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Fernando Via Canel |
| Maintainers | xaviervia |

## Links

- npm: https://www.npmjs.com/package/hoc-with-store
- Repository: https://github.com/xaviervia/hoc-with-store
- Homepage: https://github.com/xaviervia/hoc-with-store#readme
- Issues: https://github.com/xaviervia/hoc-with-store/issues
- npm.io page: https://npm.io/package/hoc-with-store

## Recent versions

- 0.1.0 (latest) — 2018-06-09
- 0.1.0-0 (rc) — 2018-06-09
- 0.0.1 — 2018-06-09

## README

# hoc-with-store

Higher-order React component for binding a Redux Store

## Install

```
yarn add hoc-with-store
```

## Usage

```js
import React from 'react'
import { render } from 'react-dom'
import { createStore } from 'redux'
import withStore from 'hoc-with-store'

const App = ({dispatch, counter}) => <div>
  {counter}
  <button  
    onClick={() => dispatch({
      type: 'ADD'
    })}>
    Add 1
  </button>
</div>

const store = createStore((state = { counter: 0 }, action) => {
  switch (action.type) {
    case 'ADD':
      return { counter: state.counter + 1 }
    default:
      return state
  }
})

const ConnectedApp = withStore(store)(App)

render(
  <ConnectedApp />,
  document.getElementById('root')
)
```

Optionally, you can pass `mapStateToProps` and `mapDispatchToProps` functions:

```js
const mapStateToProps = (state) => ({
  items: state.items.filter(({ visible }) => visible)
})

const mapDispatchToProps = (dispatch) => ({
  onAddItem: (content) => dispatch({
    type: 'ADD_ITEM',
    payload: content
  })
})

const ConnectedApp = withStore(store, mapStateToProps, mapDispatchToProps)(App)
```

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