# react-native-context-api

> Controla o context-api do react

Latest version **1.0.7** (published 2022-10-24) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install react-native-context-api
pnpm add react-native-context-api
yarn add react-native-context-api
bun add react-native-context-api
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2022-10-24 |
| First published | 2022-10-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 35.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | BuuhV Projects |
| Maintainers | buuhvprojects |
| Keywords | react-native, ios, android, context-api, context api |

## Links

- npm: https://www.npmjs.com/package/react-native-context-api
- Repository: https://github.com/buuhvprojects/react-native-context-api
- Homepage: https://github.com/buuhvprojects/react-native-context-api#readme
- Issues: https://github.com/buuhvprojects/react-native-context-api/issues
- npm.io page: https://npm.io/package/react-native-context-api

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.0.7 (latest) — 2022-10-24
- 1.0.6 — 2022-10-24
- 1.0.1 — 2022-10-24

## README

# react-native-context-api

Controla o context-api do react

## Installation

```sh
npm install react-native-context-api
```

## Usage

```js
import ContextAPI, { combineReducers } from 'react-native-context-api';
import { Store } from './interfaces';
import { systemProvider } from './stores/system';

const reducers = combineReducers({
    system: systemProvider
});
export const contextApi = new ContextAPI(reducers);

/**
 * Como Criar um uso de contexto com ContextAPI
 */
const useContextApi = (): Store => contextApi.useContext();
/**
 * Como criar um Provider ou Consumer que englobe toda a aplicação
 */
const Provider = contextApi.Provider;
const Consumer = contextApi.Consumer;

export { Provider, Consumer, useContextApi };
```

### Store

```js
import ContextAPI, { ActionProvider } from 'react-native-context-api';

const systemStore = {
    loading: true
};

export const systemProvider = (state = systemStore, action?: ActionProvider) => {
    return ContextAPI.providerResult(state, action);
};
export default systemStore;

```

### Interface

```js
import systemStore from './stores/system';
export interface DispatchParams {
    field: string;
    reducer: string;
    payload: any;
}
export interface Store {
    dispatch: (data: DispatchParams) => void;
    store: {
        system: typeof systemStore;
    };
}
export interface ContextDispatchAction<T> {
    reducer: T;
    field: string;
    payload: any;
}
export type StoresKeys = 'system';

```

### Provider

```js
function App(): JSX.Element {
    return (
        <NavigationContainer ref={navigationRef}>
            <Provider value={contextApi.providerValues}>
                {/*YOUR COMPONENT HERE*/}
            </Provider>
        </NavigationContainer>
    );
}
export default App;

```

## Contributing

See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.

## License

MIT

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