I've had problems using Map as a dependancy in useControls.
Current behaviour:
- we have
x = Map() (empty map)
- then add an item
x = Map().set('x', 1)
useControls(..., [x]) will not be triggered
This is because dequal/lite treats Map() === Map(['x', 1])
I was really surprised when I found that out
Fix:
diff --git a/dist/leva.esm.js b/dist/leva.esm.js
index 808aab75772d04a09fe2c55065ff2975d5297f77..a3e1f29fa5d910aca09cd26634fcdecc27add569 100644
--- a/dist/leva.esm.js
+++ b/dist/leva.esm.js
@@ -3,7 +3,7 @@ export { a1 as LevaInputs, a6 as LevaStoreProvider, E as useStoreContext } from
import v8n from 'v8n';
import { extend, colord, getFormat } from 'colord';
import namesPlugin from 'colord/plugins/names';
-import { dequal } from 'dequal/lite';
+import { dequal } from 'dequal';
import React, { useRef, useMemo, useLayoutEffect, useEffect, useState, useCallback, forwardRef, useImperativeHandle } from 'react';
import { RgbaColorPicker, RgbColorPicker } from 'react-colorful';
import shallow from 'zustand/shallow';
I fixed it by patching Leva dependancy in my project.
I've had problems using Map as a dependancy in
useControls.Current behaviour:
x = Map()(empty map)x = Map().set('x', 1)useControls(..., [x])will not be triggeredThis is because
dequal/litetreatsMap() === Map(['x', 1])I was really surprised when I found that out
Fix:
I fixed it by patching Leva dependancy in my project.