# react-resaga

> Generalizing boilerplate for Redux and Saga configuration

Latest version **2.0.0-beta** (published 2021-06-15) · ISC license · 0 weekly downloads

## Install

```sh
npm install react-resaga
pnpm add react-resaga
yarn add react-resaga
bun add react-resaga
```

## 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 | 2.0.0-beta |
| Published | 2021-06-15 |
| First published | 2020-03-02 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 4.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Luiz de Queiroz |
| Maintainers | luizdequeiroz |

## Links

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

## Dependencies (5)

- [saga](https://npm.io/package/saga.md) ^4.0.0-alpha
- [redux](https://npm.io/package/redux.md) ^4.1.0
- [redux-saga](https://npm.io/package/redux-saga.md) ^1.1.3
- [react-redux](https://npm.io/package/react-redux.md) ^7.2.4
- [redux-multi](https://npm.io/package/redux-multi.md) ^0.1.12

## Recent versions

- 2.0.0-beta (latest) — 2021-06-15
- 1.2.0-beta — 2020-06-10
- 1.1.0 — 2020-03-08
- 1.0.0 — 2020-03-02

## README

# react-resaga
Generalizing configuration to use of Redux and Saga

## Use Hooks

*Installing react-resaga package:*
```npm
    npm i --save react-resaga
```

*Container configuration exemple:*
```js
    import React from 'react';
    import { Container } from 'react-resaga';

    function App() {

        return (
            <Container>
                ...components
            </Container>
        );
    }
```

*Using abstract redux selector hook 'useReducers':*
```js
    import React from 'react';
    import { useReducers } from 'react-resaga';

    function EmployeesList() {
        const { employees = [] } = useReducers('employees');

        return (
            <ul>
                {employees.map((e, index) => <li key={index}>{e.name}</li>)}
            </ul>
        );
    }
```

*Container configuration exemple with sagas injection:*
```js
    import React from 'react';
    import { Container, apply } from 'react-resaga';

    function App() {

        const sagas = {
            setEmployees: function* (param) {
                yield apply('employees', param);
                yield apply('employeesLength', param.length);
            }
        };

        return (
            <Container sagas={sagas}>
                ...components
                <EmployeesList />
            </Container>
        );
    }
```

*And with useSagas and useApply:*
```js
    import React, { useEffect } from 'react';
    import { useSagas, useReducers, useApply } from 'react-resaga';
    
    function EmployeesList() {
        const { setEmployees } = useSagas();
        const { employees = [] } = useReducers('employees');
        const apply = useApply();

        useEffect(() => {
            setEmployees([
                {
                    name: 'Walter White'
                },
                {
                    name: 'Jesse Pinkman'
                },
                {
                    name: 'Gus Fring'
                }
            ]);
        }, []);

        return (
            <ul>
                {employees.map((e, index) => <li key={index}>{e.name}</li>)}
                <li onClick={() => apply('key', 'value')}></li>
            </ul>
        );
    }
```

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