How to use the shallow-equal/arrays 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 iuap-design / bee.tinper.org / tinper-bee / bee-cascader / src / rc / index.jsx View on Github external
static getDerivedStateFromProps(nextProps, prevState) {
    const { prevProps = {} } = prevState;
    const newState = {
      prevProps: nextProps,
    };

    if ('value' in nextProps && !shallowEqualArrays(prevProps.value, nextProps.value)) {
      newState.value = nextProps.value || [];

      // allow activeValue diff from value
      if (!('loadData' in nextProps)) {
        newState.activeValue = nextProps.value || [];
      }
      newState.inputValue = self.convertStringToObject(self.props.options,nextProps,[],0,).map(o =>o.label).join('/ ') || ''
    }
    if ('popupVisible' in nextProps) {
      newState.popupVisible = nextProps.popupVisible;
    }
    if ('options' in nextProps) {
			newState.options = nextProps.options || [];
    }
    if ('inputValue' in nextProps) {
      newState.inputValue = nextProps.inputValue;
github Lesha-spr / react-validation / src / components / base / index.js View on Github external
componentWillReceiveProps({ validations: nextValidations, ...nextProps }) {
    const { validations, ...props } = this.props;

    if (!shallowEqualObjects(props, nextProps) || !shallowEqualArrays(validations, nextValidations)) {
      this.context._setProps(nextProps, this.id);
    }
  }
github otakustay / react-diff-view / src / hooks / useTokenizeWorker.js View on Github external
const areHunksEqual = (xHunks, yHunks) => {
    const xChanges = findAbnormalChanges(xHunks);
    const yChanges = findAbnormalChanges(yHunks);

    return arrayShallowEquals(xChanges, yChanges);
};
github moroshko / react-autosuggest / src / Autosuggest.js View on Github external
UNSAFE_componentWillReceiveProps(nextProps) {
    if (shallowEqualArrays(nextProps.suggestions, this.props.suggestions)) {
      if (
        nextProps.highlightFirstSuggestion &&
        nextProps.suggestions.length > 0 &&
        this.justPressedUpDown === false &&
        this.justMouseEntered === false
      ) {
        this.highlightFirstSuggestion();
      }
    } else {
      if (this.willRenderSuggestions(nextProps)) {
        if (this.state.isCollapsed && !this.justSelectedSuggestion) {
          this.revealSuggestions();
        }
      } else {
        this.resetHighlightedSuggestion();
      }
github moroshko / react-autosuggest / src / Autosuggest.js View on Github external
componentDidUpdate(prevProps, prevState) {
    const {
      suggestions,
      onSuggestionHighlighted,
      highlightFirstSuggestion
    } = this.props;

    if (
      !shallowEqualArrays(suggestions, prevProps.suggestions) &&
      suggestions.length > 0 &&
      highlightFirstSuggestion
    ) {
      this.highlightFirstSuggestion();
      return;
    }

    if (onSuggestionHighlighted) {
      const highlightedSuggestion = this.getHighlightedSuggestion();
      const prevHighlightedSuggestion = prevState.highlightedSuggestion;

      if (highlightedSuggestion != prevHighlightedSuggestion) {
        onSuggestionHighlighted({
          suggestion: highlightedSuggestion
        });
      }

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