How to use the recompose.shouldUpdate function in recompose

To help you get started, we’ve selected a few recompose 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 TeselaGen / openVectorEditor / src / utils / onlyUpdateForKeysDeep.js View on Github external
const onlyUpdateForKeys = propKeys => {
  const hoc = shouldUpdate((props, nextProps) => {
    const a = !isEq(pick(nextProps, propKeys), pick(props, propKeys));
    return a;
  });

  // if (process.env.NODE_ENV !== "production") {
  //   return BaseComponent =>
  //     setDisplayName(wrapDisplayName(BaseComponent, "onlyUpdateForKeys"))(
  //       hoc(BaseComponent)
  //     );
  // }
  return hoc;
};
github commercetools / merchant-center-application-kit / packages / application-shell / src / components / fetch-user / fetch-user.js View on Github external
children: PropTypes.func.isRequired,
  // Injected
  userData: PropTypes.shape({
    isLoading: PropTypes.bool.isRequired,
    error: PropTypes.object,
    user: PropTypes.object, // see graphql query shape
  }).isRequired,
};

// React component
const FetchLoggedInUser = compose(
  setDisplayName('FetchUser'),
  graphql(LoggedInUserQuery, graphqlOptions),
  // a render is triggered because the reference of the userData prop changes
  // although the objects content didn't change
  shouldUpdate((props, nextProps) => !deepEqual(props, nextProps))
)(FetchUser);

// HoC
const withUser = mapDataToProps => Component => {
  const WrappedWithUser = props => (
    
      {userData => {
        const mappedProps = mapDataToProps
          ? mapDataToProps(userData)
          : userData;
        return ;
      }}
    
  );
  WrappedWithUser.displayName = `withUser(${getDisplayName(Component)})`;
  return WrappedWithUser;
github nick121212 / fx-schema-form / packages / fx-schema-form-react / libs / templates / card.jsx View on Github external
}
    AntdCardTemp.prototype.render = function () {
        var _a = this.props, children = _a.children, globalOptions = _a.globalOptions, tempKey = _a.tempKey, uiSchemaOptions = _a.uiSchemaOptions, mergeSchema = _a.mergeSchema, ItemButtons = _a.ItemButtons, meta = _a.meta;
        var tempOptions = Object.assign({}, globalOptions[tempKey] || {}, uiSchemaOptions[tempKey] || {});
        var uiSchema = mergeSchema.uiSchema, title = mergeSchema.title;
        var _b = meta || {}, _c = _b.isValid, isValid = _c === void 0 ? true : _c, _d = _b.errorText, errorText = _d === void 0 ? "" : _d, _e = _b.isShow, isShow = _e === void 0 ? true : _e;
        console.log("antdCardTemp render");
        return ( : ""} bodyStyle={{
            "display": isShow === false ? "none" : "block"
        }} {...tempOptions}>
                {children}
                {!isValid ? errorText : ""}
            );
    };
    AntdCardTemp = __decorate([
        compose(shouldUpdate(function () { return false; }), connect(mapMetaStateToProps), shouldUpdate(function (curProps, nextProps) {
            return !isEqual(curProps.meta, nextProps.meta);
        }))
    ], AntdCardTemp);
    return AntdCardTemp;
}(React.PureComponent));
export { AntdCardTemp };
github TeselaGen / openVectorEditor / src / utils / onlyUpdateForKeysDeepEqual.js View on Github external
const onlyUpdateForKeys = propKeys => {
  const hoc = shouldUpdate((props, nextProps) => {
    const a = !isEqual(pick(nextProps, propKeys), pick(props, propKeys));
    console.log('a:',a)
    return a;
  });

  if (process.env.NODE_ENV !== "production") {
    return BaseComponent =>
      setDisplayName(wrapDisplayName(BaseComponent, "onlyUpdateForKeys"))(
        hoc(BaseComponent)
      );
  }
  return hoc;
};
github i-novus-llc / n2o-framework / frontend / n2o-framework / src / components / widgets / Form / fields / withFieldContainer.js View on Github external
};
        }),
    }),
    withProps(props => ({
      visibleToRegister: props.visible,
      disabledToRegister:
        isBoolean(props.enabled) && !props.disabled
          ? !props.enabled
          : props.disabled,
      requiredToRegister: props.required,
    })),
    connect(
      mapStateToProps,
      mapDispatchToProps
    ),
    shouldUpdate((props, nextProps) => {
      const prevResolvedProps = omit(props.mapProps(props), excludedKeys);
      const resolvedProps = omit(props.mapProps(nextProps), excludedKeys);
      const isEqualResolvedProps = some(resolvedProps, (value, key) => {
        return !isEqual(value, prevResolvedProps[key]);
      });
      return isEqualResolvedProps;
    }),
    withProps(props => ({
      ref: props.setReRenderRef,
    })),
    pure
  )(FieldContainer);
};
github Soluto / tweek / services / editor / src / components / JPadFullEditor / JPadVisualEditor / Matcher / Matcher.js View on Github external
autofocus,
}) => (
  <div data-property="{property}" data-comp="condition">
    <button disabled="{!canBeClosed}" title="Remove condition" data-comp="delete-condition">
    
    
  </button></div>
);

const hasChanged = shouldUpdate(
  (props, nextProps) =&gt;
    !R.equals(props.matcher, nextProps.matcher) ||
    !R.equals(props.mutate.path, nextProps.mutate.path),
);

export default hasChanged(({ matcher, mutate, autofocus }) =&gt; {
  const [, props] = R.pipe(
    R.toPairs,
    R.partition(([prop]) =&gt; prop[0] === '$'),
  )(matcher);
  const ignoreActivePropsPropsPredicate = R.compose(
    R.not,
    R.contains(R.__, R.map(R.head, props)),
  );

  const allSuggestions = ContextService.getAllProperties().map((prop) =&gt; ({
github recruit-tech / redux-pluto / src / shared / components / organisms / NotFound / index.tsx View on Github external
import React from "react";
import { compose, shouldUpdate } from "recompose";

export default compose&lt;{}, {}&gt;(shouldUpdate(() =&gt; false))(function NotFound(
  props,
) {
  return <div>NotFound!</div>;
});
github nick121212 / fx-schema-form / packages / fx-schema-form-antd / out / app.js View on Github external
render() {
            const ComponentWithHoc = recompose_1.compose(react_redux_1.connect(meta_1.mapActionsStateToProps), react_redux_1.connect(null, mapDispatchToProps), recompose_1.shouldUpdate((props, nextProps) => {
                return false;
            }))(Component);
            return react_1.default.createElement(ComponentWithHoc, Object.assign({}, this.props));
        }
    }
github nick121212 / fx-schema-form / packages / fx-schema-form-react / libs / hocs / item / array.js View on Github external
render() {
                const { mergeSchema, getHocOptions } = this.props;
                const { type } = mergeSchema;
                const arrayHocOptions = getHocOptions(this.props, "array");
                const { ItemChildButtons = null, ItemButtons = null } = arrayHocOptions || {};
                let ItemChildButtonsWithHoc, ItemButtonsWithHoc;
                if (ItemChildButtons) {
                    ItemChildButtonsWithHoc = compose(shouldUpdate(() => false), connect(mapFormItemDataProps), shouldUpdate((prev, next) => {
                        let { formItemData = [] } = prev;
                        let { formItemData: formItemData1 = [] } = next;
                        if (formItemData.size && formItemData1.size) {
                            return formItemData.size !== formItemData1.size;
                        }
                        return formItemData.length !== formItemData1.length;
                    }), handlers, connect(mapMetaStateToProps), shouldUpdate((curProps, nextProps) => {
                        return !isEqual(curProps.meta, nextProps.meta);
                    }))(ItemChildButtons);
                }
                if (ItemButtons) {
                    ItemButtonsWithHoc = compose(handlers, connect(mapMetaStateToProps), shouldUpdate((curProps, nextProps) => {
                        return !isEqual(curProps.meta, nextProps.meta);
                    }))(ItemButtons);
                }
                if (type === "array") {
github recruit-tech / redux-pluto / src / shared / components / organisms / Error / index.tsx View on Github external
import React from "react";
import { compose, shouldUpdate } from "recompose";

type Props = {};

export default compose(shouldUpdate(() =&gt; false))(function Error(
  props: Props,
) {
  return <div>Error!</div>;
});