Skip to content

Commit 222ede4

Browse files
authored
Update README.md
1 parent 1a85d19 commit 222ede4

1 file changed

Lines changed: 26 additions & 2 deletions

File tree

README.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,12 @@ npm install use-restate
3434

3535
- Feather light
3636
- Avoid needless re-renders
37-
- An API that you're used to
37+
- A familiar API
3838
- Works with any Redux-like store
39-
- Memoize single/multiple action dispatch functions
39+
- Memoize single or multiple action dispatch functions
4040
- Quick access to store dispatch
4141
- Full Typescript support
42+
- Works without `react-redux`
4243

4344

4445
## Prerequisites
@@ -112,6 +113,29 @@ export default function Component() {
112113
}
113114
```
114115

116+
### `useActions(actionsMap)`
117+
118+
Wraps a map of actions in a dispatcher and memoizes each one with `useCallback`. Returns the same map with each key containing its paired action dispatcher.
119+
120+
```js
121+
import React from 'react';
122+
import { useAction } from 'use-restate';
123+
124+
export default function Component() {
125+
const { increment, decrement } = useActions({
126+
increment: { type: 'INCREMENT' },
127+
decrement: { type: 'DECREMENT' },
128+
});
129+
130+
return (
131+
<div>
132+
<a onClick={increment}>Increment count</a>
133+
<a onClick={decrement}>Decrement count</a>
134+
</div>
135+
);
136+
}
137+
```
138+
115139
### `useDispatch()`
116140

117141
Returns the `dispatch` method based on the store.

0 commit comments

Comments
 (0)