# state-selector-to-props

> A helper method which aims to simplify mapping state values to props in react-redux containers.

Latest version **1.1.0** (published 2019-04-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install state-selector-to-props
pnpm add state-selector-to-props
yarn add state-selector-to-props
bun add state-selector-to-props
```

## 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.1.0 |
| Published | 2019-04-14 |
| First published | 2019-04-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Daniel Essig |
| Maintainers | dantheuber |
| Keywords | react-redux, react, redux, state, selector |

## Links

- npm: https://www.npmjs.com/package/state-selector-to-props
- Repository: https://github.com/dantheuber/state-selector-to-props
- Homepage: https://github.com/dantheuber/state-selector-to-props#readme
- Issues: https://github.com/dantheuber/state-selector-to-props/issues
- npm.io page: https://npm.io/package/state-selector-to-props

## 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.1.0 (latest) — 2019-04-14
- 1.0.0 — 2019-04-07

## README

# state-selector-to-props
A helper method which aims to simplify mapping state values to props in react-redux containers.

## Getting Started
Install as a dependency to be used within your app:
```
yarn add state-selector-to-props
```
or
```
npm i --save state-selector-to-props
```

### How to use
This constructs your mapStateToProps method automatically for you, simpy by passing an object with the selectors like so:
```
import { connect } from 'react-redux';
import stateSelect from 'state-selector-to-props';
import { MyComponent } from './MyComponent';
import {
  mySelector1,
  mySelector2,
} from './mySelectors';

const mapStateToProps = stateSelect({
  mySelector1,
  mySelector2,
});

const container = connect(mapStateToProps)(MyComponent);

export { container as MyComponent };
```

**Note:** If your selector requires one of your components own props to be passed as a second parameter to your selector, you can add an `ownProp` attribute with the appropriate string for the prop to be passed, like so:
```
import {
  mySelector1,
  mySelector2,
} from './mySelectors';

mySelector.ownProp = 'useThisProp';

const mapStateToProps = stateSelect({
  mySelector1,
  mySelector2,
});
```
The prop value of the same name will be passed as a second paramter to your selector.

---
_Source: https://npm.io/package/state-selector-to-props · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
