@unitedstatespowersquadrons/components 1.1.3 → 1.2.0
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.
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { createContext } from "react";
|
|
2
1
|
import { Draft } from "immer";
|
|
3
2
|
import * as ReducerHandlers from "./reducerHandlers";
|
|
4
3
|
import { AppState, ServerResponse } from "./types";
|
|
@@ -27,9 +26,4 @@ export const reducer = (draft: Draft<AppState>, action: AppAction): void => {
|
|
|
27
26
|
}
|
|
28
27
|
};
|
|
29
28
|
|
|
30
|
-
const
|
|
31
|
-
const DispatchContext = createContext<React.Dispatch<AppAction> | null>(null);
|
|
32
|
-
const handlers = Object.values(ReducerHandlers);
|
|
33
|
-
|
|
34
|
-
export const { AppProvider, useAppDispatch, useAppState } =
|
|
35
|
-
buildReducer(reducer, StateContext, DispatchContext, handlers);
|
|
29
|
+
export const { AppProvider, useAppDispatch, useAppState } = buildReducer(reducer, Object.values(ReducerHandlers));
|
package/Reducer/buildReducer.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useContext, useMemo } from "react";
|
|
1
|
+
import React, { createContext, useContext, useMemo } from "react";
|
|
2
2
|
import { Draft, produce } from "immer";
|
|
3
3
|
import { useImmerReducer } from "use-immer";
|
|
4
4
|
import { ReducerHandler } from "./types";
|
|
@@ -10,10 +10,11 @@ interface InitialAppProps<AppState> {
|
|
|
10
10
|
|
|
11
11
|
export default function buildReducer<AppState, AppAction>(
|
|
12
12
|
reducer: (draft: Draft<AppState>, action: AppAction) => void,
|
|
13
|
-
StateContext: React.Context<AppState | null>,
|
|
14
|
-
DispatchContext: React.Context<React.Dispatch<AppAction> | null>,
|
|
15
13
|
handlers: ReducerHandler<AppAction>[] = []
|
|
16
14
|
) {
|
|
15
|
+
const StateContext = createContext<AppState | null>(null);
|
|
16
|
+
const DispatchContext = createContext<React.Dispatch<AppAction> | null>(null);
|
|
17
|
+
|
|
17
18
|
function AppProvider(props: InitialAppProps<AppState>) {
|
|
18
19
|
const [providerState, dispatch] = useImmerReducer(reducer, props.initialState, (state: AppState) => {
|
|
19
20
|
return produce(state, draft => draft);
|
package/Toasts/Toasts.tsx
CHANGED
package/eslint.config.mjs
CHANGED
|
@@ -153,6 +153,7 @@ export default tseslint.config(
|
|
|
153
153
|
"stylistic/semi": ["error", "always"],
|
|
154
154
|
"stylistic/no-multiple-empty-lines": "error",
|
|
155
155
|
"stylistic/jsx-sort-props": "error",
|
|
156
|
+
"stylistic/eol-last": "error",
|
|
156
157
|
"stylistic/array-element-newline": [
|
|
157
158
|
"error",
|
|
158
159
|
{
|