How to use the relay-runtime.isScalarAndEqual function in relay-runtime

To help you get started, we’ve selected a few relay-runtime 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 facebook / relay / packages / react-relay / ReactRelayFragmentContainer.js View on Github external
// Otherwise, for convenience short-circuit if all non-Relay props
      // are scalar and equal
      const keys = Object.keys(nextProps);
      for (let ii = 0; ii < keys.length; ii++) {
        const key = keys[ii];
        if (key === '__relayContext') {
          if (
            nextState.prevPropsContext.environment !==
            this.state.prevPropsContext.environment
          ) {
            return true;
          }
        } else {
          if (
            !fragments.hasOwnProperty(key) &&
            !isScalarAndEqual(nextProps[key], this.props[key])
          ) {
            return true;
          }
        }
      }
      return false;
    }
github facebook / relay / packages / react-relay / ReactRelayPaginationContainer.js View on Github external
// Otherwise, for convenience short-circuit if all non-Relay props
      // are scalar and equal
      const keys = Object.keys(nextProps);
      for (let ii = 0; ii < keys.length; ii++) {
        const key = keys[ii];
        if (key === '__relayContext') {
          if (
            nextState.prevContext.environment !==
            this.state.prevContext.environment
          ) {
            return true;
          }
        } else {
          if (
            !fragments.hasOwnProperty(key) &&
            !isScalarAndEqual(nextProps[key], this.props[key])
          ) {
            return true;
          }
        }
      }
      return false;
    }
github facebook / relay / packages / react-relay / ReactRelayPaginationContainer.js View on Github external
// Otherwise, for convenience short-circuit if all non-Relay props
      // are scalar and equal
      const keys = Object.keys(nextProps);
      for (let ii = 0; ii < keys.length; ii++) {
        const key = keys[ii];
        if (key === '__relayContext') {
          if (
            nextState.prevContext.environment !==
            this.state.prevContext.environment
          ) {
            return true;
          }
        } else {
          if (
            !fragments.hasOwnProperty(key) &&
            !isScalarAndEqual(nextProps[key], this.props[key])
          ) {
            return true;
          }
        }
      }
      return false;
    }
github ntkme / vue-relay / dist / vue-relay.esm.js View on Github external
return true;
        } // Otherwise, for convenience short-circuit if all non-Relay props
        // are scalar and equal


        var keys = Object.keys(nextProps);

        for (var ii = 0; ii < keys.length; ii++) {
          var key = keys[ii];

          if (key === '__relayContext') {
            if (this.state.prevPropsContext.environment !== nextState.prevPropsContext.environment || this.state.prevPropsContext.variables !== nextState.prevPropsContext.variables) {
              return true;
            }
          } else {
            if (!fragments.hasOwnProperty(key) && !isScalarAndEqual(nextProps[key], this.props[key])) {
              return true;
            }
          }
        }

        return false;
      },
      componentDidUpdate: function componentDidUpdate(_, prevState) {
github facebook / relay / packages / react-relay / ReactRelayRefetchContainer.js View on Github external
// Otherwise, for convenience short-circuit if all non-Relay props
      // are scalar and equal
      const keys = Object.keys(nextProps);
      for (let ii = 0; ii < keys.length; ii++) {
        const key = keys[ii];
        if (key === '__relayContext') {
          if (
            this.state.prevPropsContext.environment !==
            nextState.prevPropsContext.environment
          ) {
            return true;
          }
        } else {
          if (
            !fragments.hasOwnProperty(key) &&
            !isScalarAndEqual(nextProps[key], this.props[key])
          ) {
            return true;
          }
        }
      }
      return false;
    }
github ntkme / vue-relay / dist / vue-relay.common.js View on Github external
return true;
        } // Otherwise, for convenience short-circuit if all non-Relay props
        // are scalar and equal


        var keys = Object.keys(nextProps);

        for (var ii = 0; ii < keys.length; ii++) {
          var key = keys[ii];

          if (key === '__relayContext') {
            if (nextState.prevPropsContext.environment !== this.state.prevPropsContext.environment || nextState.prevPropsContext.variables !== this.state.prevPropsContext.variables) {
              return true;
            }
          } else {
            if (!fragments.hasOwnProperty(key) && !relayRuntime.isScalarAndEqual(nextProps[key], this.props[key])) {
              return true;
            }
          }
        }

        return false;
      },
      componentDidUpdate: function componentDidUpdate() {},
github facebook / relay / packages / react-relay / classic / container / RelayContainerComparators.js View on Github external
function isQueryDataEqual(
  fragmentPointers: Object,
  currProp: mixed,
  nextProp: mixed,
  propName: string,
): boolean {
  return (
    // resolved data did not change
    (fragmentPointers[propName] && currProp === nextProp) ||
    // otherwise compare fake data
    isScalarAndEqual(currProp, nextProp)
  );
}
github facebook / relay / packages / react-relay / classic / environment / RelayFragmentSpecResolver.js View on Github external
forEachObject(this._resolvers, (resolver, key) => {
        const prevItem = prevData[key];
        if (resolver) {
          const nextItem = resolver.resolve();
          if (nextData || nextItem !== prevItem) {
            nextData = nextData || {...prevData};
            nextData[key] = nextItem;
          }
        } else {
          const prop = this._props[key];
          const nextItem = prop !== undefined ? prop : null;
          if (nextData || !isScalarAndEqual(nextItem, prevItem)) {
            nextData = nextData || {...prevData};
            nextData[key] = nextItem;
          }
        }
      });
      this._data = nextData || prevData;
github facebook / relay / packages / react-relay / classic / environment / RelayFragmentSpecResolver.js View on Github external
forEachObject(this._resolvers, (resolver, key) => {
        const prevItem = prevData[key];
        if (resolver) {
          const nextItem = resolver.resolve();
          if (nextData || nextItem !== prevItem) {
            nextData = nextData || {...prevData};
            nextData[key] = nextItem;
          }
        } else {
          const prop = this._props[key];
          const nextItem = prop !== undefined ? prop : null;
          if (nextData || !isScalarAndEqual(nextItem, prevItem)) {
            nextData = nextData || {...prevData};
            nextData[key] = nextItem;
          }
        }
      });
      this._data = nextData || prevData;