# @raulpesilva/react-global-state

> provide global state to aplication

Latest version **0.1.5** (published 2021-01-06) · MIT license · 0 weekly downloads

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

## Install

```sh
npm install @raulpesilva/react-global-state
pnpm add @raulpesilva/react-global-state
yarn add @raulpesilva/react-global-state
bun add @raulpesilva/react-global-state
```

## Health

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

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.1.5 |
| Published | 2021-01-06 |
| First published | 2021-01-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 30.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | RaulPeSilva |
| Maintainers | raulpesilva |
| Keywords | react-native, react, ios, android, web, react context, context, react global state, global state for react |

## Links

- npm: https://www.npmjs.com/package/@raulpesilva/react-global-state
- Repository: https://github.com/raulpesilva/react-global-state
- Homepage: https://github.com/raulpesilva/react-global-state#readme
- Issues: https://github.com/raulpesilva/react-global-state/issues
- npm.io page: https://npm.io/package/@raulpesilva/react-global-state

## 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

- 0.1.5 (latest) — 2021-01-06
- 0.1.4 — 2021-01-05
- 0.1.3 — 2021-01-05

## README

# react-global-state

Easy way to provide global state to reactJS and React Native applications

## Installation

```sh
npm install @raulpesilva/react-global-state
```
or

```sh
yarn add @raulpesilva/react-global-state
```

## Usage

```js
import * as React from 'react';

import { StyleSheet, View, Text, Button } from 'react-native';
import useGlobalState, { GlobalStateProvider } from '@raulpesilva/react-global-state';

const Foo: React.FC = () => {
  const [value, setValue] = useGlobalState('value', 0);

  return (
    <View style={styles.container}>
      <Button onPress={() => { setValue(value + 1) }} title=" + " />
      <Text>resultado é : {value}</Text>
      <Button onPress={() => { setValue(value > 0 ? value - 1 : 0) }} title=" - " />
    </View>
  );
};
const Bar: React.FC = () => {
  const [value] = useGlobalState('value');

  return (
    <View style={styles.container}>
      <Text>resultado é : {value}</Text>
    </View>
  );
};

export default function App() {
  return (
    <GlobalStateProvider>
      <View style={styles.container}>
        <Foo />
        <Bar />
      </View>
    </GlobalStateProvider>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
  },
});

```

## 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/@raulpesilva/react-global-state · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
