Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mintsweet/reate

:fire: A lightweight react global state management library
https://github.com/mintsweet/reate

Last synced: about 2 months ago
JSON representation

:fire: A lightweight react global state management library

Awesome Lists containing this project

README

        

# Reate

> A lightweight react global state management library.

## ✨ Feature

- Simple and easy to use, only three APIs.
- Only 4kb size after build.
- Support TypeScript static check.
- No dependencies.

## 🌈 Install

```bash
$ npm i reate --save
```

## 😊 Usage

**create a store**

```javascript
// store.js
import Reate from 'reate';

export default new Reate(
{
visible: false,
},
{
changeVisible: (store, { visible }) => store.setState({ visible });
}
);
```

**use this store in react**

```javascript
// Test.js
import React from 'react';
import store from './store.js';

function Test() {
const visible = store.useState('visible');
return (


store.dispatch('changeVisible', { visible: !visible })}
>
ChangeVisible

{visible ?
Hide
:
Show
}

);
}
```

## 🔨 License

[MIT](LICENSE)