Skip to content

Commit 0a0820d

Browse files
committed
added basic README info
1 parent 875ee1c commit 0a0820d

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,25 @@
11
# shared-react-variables
2-
Shared React variables
2+
3+
Easy and comfortable React state manager.
4+
5+
## API
6+
7+
### **createUseSharedVariable**
8+
Takes initial state as a parameter. Returns a hook can be imported and used anywhere in your application. When you use this hook, it returns you mutable global state. Whenever this state is changed component will be rerendered (this behaviour can be changed via *rerenderOnChange* flag).
9+
10+
#### Signature
11+
```ts
12+
function createUseSharedVariable<T extends object>(initialState: T): (rerenderOnChange?: boolean) => T
13+
```
14+
15+
#### Usage example
16+
```ts
17+
// feel free to use this state hook anywhere!
18+
const useTimer = createUseSharedVariable({ ticks: 0 });
19+
20+
export { useTimer }
21+
```
22+
23+
## Example
24+
25+
https://codesandbox.io/s/react-shared-variables-example-f7feo7

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@alevnyacow/shared-react-variables",
3-
"version": "0.0.3",
3+
"version": "1.0.0",
44
"description": "Easy and comfortable React state manager",
55
"main": "transpiled/index.js",
66
"scripts": {
@@ -48,5 +48,5 @@
4848
"bugs": {
4949
"url": "https://github.com/alevnyacow/shared-react-variables/issues"
5050
},
51-
"homepage": "https://github.com/alevnyacow/shared-react-variables#readme"
51+
"homepage": "https://codesandbox.io/s/react-shared-variables-example-f7feo7"
5252
}

0 commit comments

Comments
 (0)