@unitedstatespowersquadrons/components 1.2.3 → 1.2.4-pre.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/FontAwesomeIcon.tsx
CHANGED
package/Readme.md
CHANGED
|
@@ -49,17 +49,8 @@ More detailed information is available for [Toasts](Toasts/Readme.md) usage.
|
|
|
49
49
|
To create a reducer, follow the following pattern, follow the pattern described
|
|
50
50
|
in [Reducer/Example](Reducer/Example).
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
If you only need access to app state, but no dispatchable events, you can use
|
|
55
|
-
the simplified generator function:
|
|
56
|
-
|
|
57
|
-
```ts
|
|
58
|
-
import { buildUnreducableState } from "@unitedstatespowersquadrons/components";
|
|
59
|
-
import { AppState } from "./types";
|
|
60
|
-
|
|
61
|
-
export const { AppProvider, useAppState } = buildUnreducableState<AppState>();
|
|
62
|
-
```
|
|
52
|
+
There is also an example in `appstate.tsx` for if you only need access to app
|
|
53
|
+
state, but do not have any dispatchable events.
|
|
63
54
|
|
|
64
55
|
## Automated Testing
|
|
65
56
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { useAppDispatch, useAppState } from "./reducer";
|
|
3
|
+
|
|
4
|
+
const SubComponent = () => {
|
|
5
|
+
const { something } = useAppState();
|
|
6
|
+
const dispatch = useAppDispatch();
|
|
7
|
+
|
|
8
|
+
const handleDoSomething = () => {
|
|
9
|
+
const newSomething = "changed";
|
|
10
|
+
|
|
11
|
+
dispatch({ something: newSomething, type: "doSomething" });
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
return(
|
|
15
|
+
<div onClick={handleDoSomething}>
|
|
16
|
+
{something}
|
|
17
|
+
</div>
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export default SubComponent;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { AppProvider } from "./reducer";
|
|
3
|
+
import { AppState } from "./types";
|
|
4
|
+
import SubComponent from "./SubComponent";
|
|
5
|
+
|
|
6
|
+
const Example = (props: AppState) => {
|
|
7
|
+
return(
|
|
8
|
+
<AppProvider initialState={props}>
|
|
9
|
+
<SubComponent />
|
|
10
|
+
</AppProvider>
|
|
11
|
+
);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default Example;
|