Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/meftunca/react-state


https://github.com/meftunca/react-state

Last synced: 27 days ago
JSON representation

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).