How to use the shallow-equal.shallowEqualObjects function in shallow-equal

To help you get started, we’ve selected a few shallow-equal 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 RealmTeam / react-redux-reliever / src / connect.js View on Github external
return (state, ownProps) => {
      const nextProps = props(state, ownProps)
      if (shallowEqualObjects(prevProps, nextProps)) return prevResult
      const nextResult = {...nextProps, ...functions(nextProps, dispatch)}
      prevResult = nextResult
      prevProps = nextProps
      return nextResult
    }
  }, {
github redux-model / redux-model / src / core / utils / persist.ts View on Github external
export const setPersistConfig = (persist: ReduxStoreConfig['persist']): void => {
  if (config && shallowEqualObjects(config, persist)) {
    return;
  }

  config = persist;

  if (config) {
    ready = false;
    setStorage(config.storage);
    whiteList = config.whitelist ? config.whitelist.map((item) => item.getReducerName()) : [];
    blackList = config.blacklist ? config.blacklist.map((item) => item.getReducerName()) : [];
    defaultPersistOption.__persist.version = config.version;
  } else {
    persistIsReady();
  }
};
github TimboKZ / Chonky / src / components / FileBrowser.tsx View on Github external
public componentDidUpdate(prevProps: Readonly, prevState: Readonly): void {
        const {onSelectionChange} = this.props;
        const {
            rawFiles: oldRawFiles, selection: oldSelection, options: oldOptions,
            sortProperty: oldSortProperty, sortOrder: oldSortOrder,
        } = prevState;
        const {rawFiles, selection, options, sortProperty, sortOrder} = this.state;

        let justChangedSelection = false;

        const needToResort = !shallowEqualArrays(rawFiles, oldRawFiles)
            || !shallowEqualObjects(options, oldOptions)
            || sortProperty !== oldSortProperty
            || sortOrder !== oldSortOrder;
        if (needToResort) {
            const [sortedFiles, fileIndexMap] = FileUtil.sortFiles(rawFiles, options, sortProperty, sortOrder);
            const newState: Partial = {sortedFiles, fileIndexMap};

            const newSelection = {};
            let additionCount = 0;
            for (const file of sortedFiles) {
                if (isNil(file) || selection[file.id] !== true) continue;
                newSelection[file.id] = true;
                additionCount++;
            }
            if (additionCount !== Object.keys(selection).length) {
                newState.selection = newSelection;
                justChangedSelection = true;
github cssinjs / jss / packages / react-jss / src / JssProvider.js View on Github external
context.classNamePrefix += classNamePrefix
    }

    if (media !== undefined) {
      context.media = media
    }

    if (jss) {
      context.jss = jss
    }

    if (disableStylesGeneration !== undefined) {
      context.disableStylesGeneration = disableStylesGeneration
    }

    if (prevContext && shallowEqualObjects(prevContext, context)) {
      return prevContext
    }

    return context
  }

shallow-equal

Typescript-compatible minimalistic shallow equality check for arrays/objects

MIT
Latest version published 2 years ago

Package Health Score

71 / 100
Full package analysis