Skip to content

Commit 0f7f6e2

Browse files
authored
Merge pull request #4 from react-gx/dev
Version 1.2.1
2 parents 5224154 + 32dc50a commit 0f7f6e2

27 files changed

+613
-581
lines changed

README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
[![GitHub license](https://img.shields.io/github/license/react-gx/gx)](https://github.com/react-gx/gx/blob/main/LICENSE)
88

99

10-
![logo](./assets/logo.png)
10+
![logo](https://lh4.googleusercontent.com/k2V9Oh-tfABeDjwovtMUqE-lt6cULH0c1EFgb-XNTFh1lt5DVGTGhl3Ty3fMF3xhCBY=w2400)
11+
1112

1213
This library aims to provide you an `easy` and `fast` way to set up and manage the global state of your **`react`** application.
1314

@@ -123,7 +124,7 @@ For structuring your code very well you have to follow these steps.
123124

124125
Here is the result.
125126

126-
![structure](./assets/structure.png)
127+
![structure](https://lh3.googleusercontent.com/_z_JTStNFHyXTmjz4GrcphAN6BC_CeKYxN1zwyxWGC-ujpIcVTqthesXT6Lfe8b4t1M=w2400)
127128

128129
### Second step: Creating your signals.
129130

@@ -184,19 +185,19 @@ export default App;
184185

185186
### Fifth step: Using your signals.
186187

187-
Create a component called `Counter` inside the Counter.js file. Then import two hooks from `gx` called `useSignal` and `useAction` like follow.
188+
Create a component called `Counter` inside the Counter.js file. Then import two hooks from `gx` called `useSignal` and `useActions` like follow.
188189

189190

190191
```js
191192
import React from "react";
192-
import { useSignal, useAction } from "@dilane3/gx";
193+
import { useSignal, useActions } from "@dilane3/gx";
193194

194195
function Counter() {
195196
// State
196197
const counter = useSignal("counter");
197198

198199
// Actions
199-
const { increment, decrement } = useAction("counter");
200+
const { increment, decrement } = useActions("counter");
200201

201202
return (
202203
<div>
@@ -278,30 +279,29 @@ This hook takes the name of the signal as a parameter and returns the state cont
278279
const counter = useSignal("counter");
279280
```
280281

281-
### `useAction`
282+
### `useActions`
282283

283284
This hook takes the name of the signal as a the first parameter and returns an object that contains all the actions of this signal.
284285

285286
```js
286-
const { increment, decrement } = useAction("counter");
287+
const { increment, decrement } = useActions("counter");
287288
```
288289

289-
**`New in version 1.1.0`**
290-
291-
Note that, the `useAction` hook can accept a second parameter which is the list of actions that you want to use. If you don't specify the second parameter, all the actions of the signal will be returned.
290+
### `useAction`
292291

293-
There is another thing that you have to know.
294-
If you provide only one action as a second parameter, the hook will return only the action itself and not an object that contains the action.
292+
This hook takes the name of the signal as the first parameter and the name of the action as the second one and then return that action.
295293

296294
```js
297295
const increment = useAction("counter", "increment");
298296
```
299297

300-
And if you provide more than one action, the hook will return an object that contains all the actions provided.
298+
See more on the [documentation](https://gx.dilane3.com/docs/guide/hooks/useAction)
301299

302-
```js
303-
const { increment, decrement } = useAction("counter", "increment", "decrement");
304-
```
300+
## TypeScript Support
301+
302+
`GX` support TypeScript, so that you can use it directly into your application.
303+
304+
See how to integrate it on the [documentation](https://gx.dilane3.com/docs/typescript) website
305305

306306
## License
307307

assets/logo.png

-51.1 KB
Binary file not shown.

assets/structure.png

-28.6 KB
Binary file not shown.

dist/hooks/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export type Action = {
1+
export type Actions = {
22
[key: string]: (payload: any) => void;
33
};

dist/hooks/useAction.d.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
declare const useAction: (signalName: string, ...actions: string[]) => ((payload: any) => void) | {
2-
[key: string]: (payload: any) => void;
3-
};
1+
declare const useAction: (signalName: string, action: string) => (payload: any) => void;
42
export default useAction;

dist/hooks/useAction.js

Lines changed: 8 additions & 62 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/hooks/useAction.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/hooks/useActions.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { Actions } from "./types";
2+
declare const useActions: (signalName: string, ...actions: string[]) => Actions;
3+
export default useActions;

dist/hooks/useActions.js

Lines changed: 53 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/hooks/useActions.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)