@zohodesk/utils 1.0.8 → 1.0.11
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/es/reducerHandler.js +15 -23
- package/package.json +2 -2
package/es/reducerHandler.js
CHANGED
|
@@ -1,23 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
// };
|
|
17
|
-
// const [state, dispatch] = useReducer(proxyReducer, initialArg, init);
|
|
18
|
-
|
|
19
|
-
// return {
|
|
20
|
-
// state,
|
|
21
|
-
// dispatch
|
|
22
|
-
// };
|
|
23
|
-
// }
|
|
1
|
+
import { useReducer } from 'react';
|
|
2
|
+
export default function useCommonReducer(defaultReducer, customReducer, initialArg, init) {
|
|
3
|
+
const proxyReducer = (state, action) => {
|
|
4
|
+
let lastState = defaultReducer(state, action);
|
|
5
|
+
if (customReducer) {
|
|
6
|
+
return customReducer(lastState, action);
|
|
7
|
+
}
|
|
8
|
+
return lastState;
|
|
9
|
+
};
|
|
10
|
+
const [state, dispatch] = useReducer(proxyReducer, initialArg, init);
|
|
11
|
+
return {
|
|
12
|
+
state,
|
|
13
|
+
dispatch
|
|
14
|
+
};
|
|
15
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zohodesk/utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
4
4
|
"description": "Unified Component Library - Utils",
|
|
5
5
|
"main": "es/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"es",
|
|
32
32
|
"!**/__tests__"
|
|
33
33
|
],
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "d8ce1587ba7ced140c28d3909b7489b2306eee27"
|
|
35
35
|
}
|