@cripty2001/utils 0.0.81 → 0.0.82

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.
@@ -104,21 +104,21 @@ function useSynced(def, value, setValue) {
104
104
  if ((value !== undefined && setValue === undefined) ||
105
105
  (value === undefined && setValue !== undefined))
106
106
  throw new Error('Either value and setValue must be provided, or both must be undefined');
107
+ const setValueRef = (0, react_1.useRef)(setValue);
108
+ (0, react_1.useEffect)(() => {
109
+ setValueRef.current = setValue;
110
+ }, [setValue]);
107
111
  if (value !== undefined && setValue !== undefined) {
108
112
  (0, react_1.useEffect)(() => {
109
- // console.log('syncing value downstream', value, '->', v);
110
113
  if ((0, lodash_1.isEqual)(v, value))
111
114
  return;
112
- // console.log("SYNCED")
113
115
  setV(value);
114
116
  }, [value, v, setV]);
115
117
  (0, react_1.useEffect)(() => {
116
- // console.log('syncing value upstream', v, '->', value);
117
118
  if ((0, lodash_1.isEqual)(v, value))
118
119
  return;
119
- // console.log("SYNCED");
120
- setValue(v);
121
- }, [v, value, setValue]);
120
+ setValueRef.current?.(v);
121
+ }, [v, value]);
122
122
  }
123
123
  return [v, setV];
124
124
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cripty2001/utils",
3
- "version": "0.0.81",
3
+ "version": "0.0.82",
4
4
  "description": "Internal Set of utils. If you need them use them, otherwise go to the next package ;)",
5
5
  "homepage": "https://github.com/cripty2001/utils#readme",
6
6
  "bugs": {