How to use dequal - 9 common examples

To help you get started, we’ve selected a few dequal examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github idena-network / idena-desktop / renderer / shared / providers / identity-context.js View on Github external
async function fetchData() {
        try {
          const nextIdentity = await fetchIdentity()
          if (!deepEqual(identity, nextIdentity)) {
            const state =
              identity &&
              identity.state === IdentityStatus.Terminating &&
              nextIdentity &&
              nextIdentity.state !== IdentityStatus.Undefined // still mining
                ? identity.state
                : nextIdentity.state
            setIdentity({...nextIdentity, state})
          }
        } catch (error) {
          global.logger.error(
            'An error occured while fetching identity',
            error.message
          )
        }
      }
github meltyshev / planka / client / src / components / CardModal / Actions / EditComment.jsx View on Github external
const submit = useCallback(() => {
    const cleanData = {
      ...data,
      text: data.text.trim(),
    };

    if (!cleanData.text) {
      textField.current.ref.current.select();
      return;
    }

    if (!dequal(cleanData, defaultData)) {
      onUpdate(cleanData);
    }

    close();
  }, [defaultData, onUpdate, data, close]);
github nearform / graphql-hooks / packages / graphql-hooks / src / useClientRequest.js View on Github external
function useDeepCompareCallback(callback, deps) {
  const ref = React.useRef()

  if (!deepEqual(deps, ref.current)) {
    ref.current = deps
  }

  return React.useCallback(callback, ref.current)
}
github meltyshev / planka / client / src / components / LabelsStep / EditStep.jsx View on Github external
const handleSubmit = useCallback(() => {
    const cleanData = {
      ...data,
      name: data.name.trim() || null,
    };

    if (!dequal(cleanData, defaultData)) {
      onUpdate(cleanData);
    }

    onBack();
  }, [defaultData, data, onUpdate, onBack]);
github zhw2590582 / SubPlayer / src / components / Blocks.js View on Github external
static getDerivedStateFromProps(props, state) {
        const subtitles = props.subtitles.filter(item => {
            return (
                (item.startTime >= props.beginTime && item.startTime <= props.beginTime + 10) ||
                (item.endTime >= props.beginTime && item.endTime <= props.beginTime + 10)
            );
        });

        return dequal(subtitles, state.subtitles)
            ? null
            : {
                  subtitles,
              };
    }
github meltyshev / planka / client / src / components / EditTimerStep / EditTimerStep.jsx View on Github external
hoursField.current.select();
      return;
    }

    if (Number.isNaN(parts.minutes) || parts.minutes > 60) {
      minutesField.current.select();
      return;
    }

    if (Number.isNaN(parts.seconds) || parts.seconds > 60) {
      secondsField.current.select();
      return;
    }

    if (defaultValue) {
      if (!dequal(parts, getTimerParts(defaultValue))) {
        onUpdate(updateTimer(defaultValue, parts));
      }
    } else {
      onUpdate(createTimer(parts));
    }

    onClose();
  }, [defaultValue, onUpdate, onClose, data]);
github idena-network / idena-desktop / renderer / shared / providers / epoch-context.js View on Github external
useInterval(async () => {
    try {
      const nextEpoch = await fetchEpoch()
      if (!deepEqual(epoch, nextEpoch)) {
        setEpoch(nextEpoch)
      }
    } catch (error) {
      global.logger.error(
        'An error occured while fetching epoch',
        error.message
      )
    }
  }, interval)
github kentcdodds / use-deep-compare-effect / src / index.js View on Github external
function useDeepCompareMemoize(value) {
  const ref = React.useRef()

  if (!deepEqual(value, ref.current)) {
    ref.current = value
  }

  return ref.current
}
github meltyshev / planka / client / src / components / Project / EditPopup.jsx View on Github external
const handleSubmit = useCallback(() => {
    const cleanData = {
      ...data,
      name: data.name.trim(),
    };

    if (!cleanData.name) {
      nameField.current.select();
      return;
    }

    if (!dequal(cleanData, defaultData)) {
      onUpdate(cleanData);
    }

    onClose();
  }, [defaultData, onUpdate, onClose, data]);

dequal

A tiny (304B to 489B) utility for check for deep equality

MIT
Latest version published 2 years ago

Package Health Score

73 / 100
Full package analysis

Popular dequal functions