@lowentry/react-redux 1.0.4 → 1.1.2

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.
Files changed (2) hide show
  1. package/LeRed.js +13 -3
  2. package/package.json +1 -1
package/LeRed.js CHANGED
@@ -14,7 +14,7 @@ export const LeRed = (() =>
14
14
 
15
15
  try
16
16
  {
17
- const set = (value, key, ignoreOverrides = false) =>
17
+ const set = (key, value, ignoreOverrides = false) =>
18
18
  {
19
19
  const keyFirstChar = key.charAt(0);
20
20
  if(keyFirstChar === keyFirstChar.toLowerCase() && (keyFirstChar !== keyFirstChar.toUpperCase()))
@@ -43,11 +43,11 @@ export const LeRed = (() =>
43
43
  {
44
44
  LeUtils.each(obj, (value, key) =>
45
45
  {
46
- set(value, key, ignoreOverrides);
46
+ set(key, value, ignoreOverrides);
47
47
  }, optionalSkipHasOwnPropertyCheck);
48
48
  };
49
49
 
50
- LeRed.set = (value, key) => set(value, key, true);
50
+ LeRed.set = (key, value) => set(key, value, true);
51
51
  LeRed.setAll = (obj, optionalSkipHasOwnPropertyCheck = true) => setAll(obj, true, optionalSkipHasOwnPropertyCheck);
52
52
 
53
53
  setAll(ReactDOM);
@@ -826,6 +826,16 @@ export const LeRed = (() =>
826
826
  return React.useMemo(callable, comparingValues);
827
827
  };
828
828
 
829
+ LeRed.useCallback = (callable, comparingValues, equalsComparator) =>
830
+ {
831
+ equalsComparator = fixEqualsComparator(equalsComparator, 'LeRed.useCallback() was given an invalid comparator:');
832
+ comparingValues = ARRAY(comparingValues);
833
+ // eslint-disable-next-line react-hooks/rules-of-hooks
834
+ comparingValues = comparingValues.map(value => useCompareMemoize(value, equalsComparator));
835
+ // eslint-disable-next-line react-hooks/exhaustive-deps
836
+ return React.useCallback(callable, comparingValues);
837
+ };
838
+
829
839
  LeRed.usePrevious = (value, initialValue) =>
830
840
  {
831
841
  const ref = LeRed.useRef(initialValue);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowentry/react-redux",
3
- "version": "1.0.4",
3
+ "version": "1.1.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Provides utilities for React and Redux.",