# react-redux-typed-hooks

> Typed hooks for react-redux

Latest version **1.0.1** (published 2020-02-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-redux-typed-hooks
pnpm add react-redux-typed-hooks
yarn add react-redux-typed-hooks
bun add react-redux-typed-hooks
```

## 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.1 |
| Published | 2020-02-19 |
| First published | 2020-02-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 2.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Marton Sari |
| Maintainers | sarimarton |
| Keywords | react, redux, typescript, hooks |

## Links

- npm: https://www.npmjs.com/package/react-redux-typed-hooks
- Repository: https://github.com/sarimarton/react-redux-typed-hooks
- Homepage: https://github.com/sarimarton/react-redux-typed-hooks#readme
- Issues: https://github.com/sarimarton/react-redux-typed-hooks/issues
- npm.io page: https://npm.io/package/react-redux-typed-hooks

## 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.1 (latest) — 2020-02-19
- 1.0.0 — 2020-02-19

## README

# react-redux-typed-hooks

Typed hooks for react-redux. [Read more about it here.](https://dev.to/sarimarton/easy-type-safety-with-usedispatch-and-useselector-4fii)

## Usage:

- Define your _store_ and _store event_ types (store events are objects which are passed to the `dispatch` function).
- Get the hooks from the factory provided by this package, and export them.
- Enjoy.

## Example:

```tsx
// store/index.ts

import { createStore, combineReducers } from 'redux'
import getHooks from 'react-redux-typed-hooks'

import fruits, { FruitStore, FruitStoreEvent } from './fruits'
import others, { OtherStore, OtherStoreEvent } from './others'

type Event = FruitStoreEvent | OtherStoreEvent

interface Store {
  fruits: FruitStore;
  others: OtherStore;
}

export const { useSelector, useDispatch } = getHooks<Store, Event>()

export default createStore(
  combineReducers({
    fruits,
    others
  })
)
```

In your component files:
```tsx
// view/component.tsx

// import { useDispatch, useSelector } from 'react-redux' // WRONG
import { useSelector, useDispatch } from '../store'
```

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