You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+23-27Lines changed: 23 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,23 @@
1
1
# useRestate
2
2
3
-
A React hook that subscribes your state selector to the store.
4
-
3
+
A React Hook that subscribes your state selector to the store and memoizes your action dispatchers.
4
+
5
+
```js
6
+
functionCount() {
7
+
constincrement=useAction({ type:'INCREMENT' });
8
+
const { count } =useRestate(state=> {
9
+
return { count:state.count };
10
+
});
11
+
12
+
return (
13
+
<div>
14
+
<h2>{count}</h2>
15
+
<button onClick={increment}>Increment</button>
16
+
</div>
17
+
);
18
+
}
19
+
```
20
+
5
21
## Install
6
22
7
23
```bash
@@ -20,47 +36,27 @@ npm install use-restate
20
36
- Works with any Redux-like store
21
37
- Memoized action dispatch functions
22
38
- Quick access to store dispatch
23
-
- Typescript support
39
+
-Full Typescript support
24
40
25
41
26
42
## Prerequisites
27
43
28
-
React hooks require react & react-dom at version 16.7.0-alpha.0 or higher.
44
+
⚠️ React hooks require `react` & `react-dom` at version 16.7.0-alpha.0 or higher.
29
45
30
46
## Usage
31
47
32
-
`use-restate` requires you to provide your Redux-like store to `RestateProvider`.
48
+
The `use-restate` package requires you to provide your Redux-like store to `RestateProvider`.
33
49
34
50
### Setting up the store
35
51
36
-
Before using the hook, your store should be passed to `RestateProvider`.
52
+
Before using the hook, your store should be passed to `RestateProvider`. You also have access to `RestateContext` should you need it to inject middleware.
0 commit comments