https://github.com/meftunca/react-state
https://github.com/meftunca/react-state
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/meftunca/react-state
- Owner: meftunca
- Created: 2019-08-01T02:04:45.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T05:57:29.000Z (over 2 years ago)
- Last Synced: 2025-03-17T22:07:26.214Z (4 months ago)
- Language: JavaScript
- Size: 2.19 MB
- Stars: 0
- Watchers: 0
- 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 😇
[](https://www.npmjs.com/package/@devloops/react-state)
[](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).