Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/meftunca/react-state
https://github.com/meftunca/react-state
Last synced: 27 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/meftunca/react-state
- Owner: meftunca
- Created: 2019-08-01T02:04:45.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T05:57:29.000Z (about 2 years ago)
- Last Synced: 2024-11-28T10:15:26.785Z (about 1 month ago)
- Language: JavaScript
- Size: 2.19 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 45
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# @devloops/react-state
> React Global Context State (Gzipped 1.1 KB) 💥💥💥
> Please let me know your feedback 😇
[![NPM](https://img.shields.io/npm/v/@devloops/react-state.svg)](https://www.npmjs.com/package/@devloops/react-state)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)## Install
```bash
npm install --save @devloops/react-state
```## [Demo](https://meftunca.github.io/react-state/)
## Usage
```jsx
import React, { Component } from "react";
import { GStateProvider, useGState, decorate } from "@devloops/react-state";
class Store {
increment = () => {
++this.value;
};
decrement = () => {
--this.value;
};value = 10;
setName = name => {
console.log("name", name);
this.name = name;
};name = "By Devloops";
}const pointFunc = decorate(Store, {
increment: "actionWithPerformance",
decrement: "actionWithPerformance",
setName: "actionWithPerformance",
value: "observable",
name: "observable"
});
const App = () => {
return (
);
};
const Test = useGState("point")(({ point }) => {
return (
{
point.setName(target.value, "asdas");
}}
/>
Score
{point.value}
{
point.increment();
//or
point.value = point.value + 1;
}}
>
increase
{
point.decrement();
//or
point.value = point.value - 1;
}}
>
decrease
)
}))```
## License
MIT © [meftunca](https://github.com/meftunca)
---
This hook is created using [create-react-hook](https://github.com/hermanya/create-react-hook).