# react-function-helpers

> some useful react function helpers :)

Latest version **1.2.8** (published 2020-02-24) · ISC license · 0 weekly downloads

## Install

```sh
npm install react-function-helpers
pnpm add react-function-helpers
yarn add react-function-helpers
bun add react-function-helpers
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.8 |
| Published | 2020-02-24 |
| First published | 2020-01-02 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 115.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | ms0223900 |

## Links

- npm: https://www.npmjs.com/package/react-function-helpers
- Repository: https://github.com/ms0223900/react-function-helpers
- Homepage: https://github.com/ms0223900/react-function-helpers#readme
- Issues: https://github.com/ms0223900/react-function-helpers/issues
- npm.io page: https://npm.io/package/react-function-helpers

## Dependencies (1)

- [serve](https://npm.io/package/serve.md) ^11.3.0

## Recent versions

- 1.2.8 (latest) — 2020-02-24
- 1.2.7 — 2020-02-21
- 1.2.6 — 2020-02-21
- 1.2.5 — 2020-02-12
- 1.2.4 — 2020-02-11
- 1.2.3 — 2020-01-16
- 1.2.2-beta — 2020-01-16
- 1.2.2-alpha — 2020-01-15
- 1.2.2 — 2020-01-15
- 1.2.1 — 2020-01-15
- 1.2.0 — 2020-01-15
- 1.1.0 — 2020-01-03
- 1.0.1 — 2020-01-02
- 1.0.0 — 2020-01-02

## README

# react function helpers

## mapStateToProps
just like redux "mapStateToProps", but you must provider types if you use TypeScript

```
type OwnProps = { index: number, listData: SingleEstimateStop }

const mapStateToProps: MapStateToProps<DrivingMapState,OwnProps, {
  isSelected: boolean
}> = (state, ownProps) => ({
  isSelected: ownProps.index === state.selectedRouteStopIndex
});
```

## mapDispatchToProps
just like redux "mapDispatchToProps", but you must provider types if you use TypeScript

```
const mapDispatchToProps: MapDispatchToProps<OwnProps, {
  listClickFn: (routeStopId: number) => any
}> = (dispatch) => ({
  listClickFn: (routeStopId: number) => {
    dispatch(setRouteStopId(routeStopId));
  }
});
```

## connectCtx
just like redux "connect", but you should provider context ContextStore for each use.

```
const ComponentWithCtx = connectCtx(ContextStore)(mapStateToProps?, mapDispatchToProps?)(Component)
```

## combineReducers
just like redux "combineReducers"

```
interface CollinearRoutesState {
  selectedRouteId: SelectedRouteId
  stopSearchFromTo: StopSearchFromTo
}

const reducers = combineReducers<CollinearRoutesState>({
  selectedRouteId: selectedRouteId_reducer,
  stopSearchFromTo: stopSearchFromTo_reducer,
});
```

---

## createContextValueFn
createContextValueFn create a function with custom state/dispatch paramters for ContextWrapper

```
const initState = {//context state...}
const reducers = {//reducers}

const ContextValueFn = createContextValueFn(initState, reducers);
```

## createContextStore
just create a ContextStore

```
const initState = {//context state...}
const ContextStore = createContextStore(initState, dispatch?)
```

## ContextWrapperFn
create a ContextWrapper

```
export const ContextWrapper = ContextWrapperFn(ContextValueFn, ContextStore);

//wrap a component which consume context
<ContextWrapper>
  <Component>
</ContextWrapper>
```

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