@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.
@@ -12,7 +12,7 @@ export interface FontAwesomeProps {
12
12
 
13
13
  const useStyles = createUseStyles({
14
14
  icon: {
15
- padding: "0.25em 0.5em",
15
+ padding: "0.25em",
16
16
  },
17
17
  });
18
18
 
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
- ### State without Dispatch
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,4 @@
1
+ import { AppState } from "./types";
2
+ import buildUnreducibleState from "../buildUnreducibleState";
3
+
4
+ export const { AppProvider, useAppState } = buildUnreducibleState<AppState>();
@@ -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;
@@ -17,7 +17,7 @@ export const reducer = (draft: Draft<AppState>, action: AppAction): void => {
17
17
 
18
18
  switch (type) {
19
19
  case "doSomething":
20
- draft.something = "changed";
20
+ draft.something = action.something;
21
21
 
22
22
  break;
23
23
  case "saveComplete": break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unitedstatespowersquadrons/components",
3
- "version": "1.2.3",
3
+ "version": "1.2.4-pre.1",
4
4
  "description": "USPS shared React components library",
5
5
  "main": "index.tsx",
6
6
  "scripts": {