Skip to content

use full dequal version #610

Description

@nionis

I've had problems using Map as a dependancy in useControls.

Current behaviour:

  1. we have x = Map() (empty map)
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions