How to use the react-is.isContextConsumer function in react-is

To help you get started, we’ve selected a few react-is 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 lolatravel / realm-react-redux / src / components / connectAdvanced.js View on Github external
const ContextToUse = useMemo(() => {
                // Users may optionally pass in a custom context instance to use instead of our ReactReduxContext.
                // Memoize the check that determines which context instance we should use.
                return propsContext &&
                propsContext.Consumer &&
                isContextConsumer()
                    ? propsContext
                    : Context;
            }, [propsContext, Context]);
github fusionjs / fusion-react-async / src / prepare.js View on Github external
function prepareElement(element, context) {
  if (element === null || typeof element !== 'object') {
    return Promise.resolve([null, context]);
  }
  const {type, props} = element;
  if (isContextConsumer(element)) {
    return Promise.resolve([props.children(type._currentValue), context]);
  }
  if (isContextProvider(element)) {
    type._context._currentValue = props.value;
    return Promise.resolve([props.children, context]);
  }
  if (typeof type === 'string' || isFragment(element)) {
    return Promise.resolve([props.children, context]);
  }
  if (!isReactCompositeComponent(type)) {
    return Promise.resolve([type(props, context), context]);
  }
  const CompositeComponent = type;
  const instance = new CompositeComponent(props, context);
  instance.props = props;
  instance.context = context;
github airbnb / enzyme / packages / enzyme-adapter-react-16.3 / src / ReactSixteenThreeAdapter.js View on Github external
isContextConsumer(type) {
    return !!type && isContextConsumer(makeFakeElement(type));
  }
github airbnb / enzyme / packages / enzyme-adapter-react-16.3 / src / ReactSixteenThreeAdapter.js View on Github external
isCustomComponent(type) {
    const fakeElement = makeFakeElement(type);
    return !!type && (
      typeof type === 'function'
      || isForwardRef(fakeElement)
      || isContextProvider(fakeElement)
      || isContextConsumer(fakeElement)
    );
  }
github airbnb / enzyme / packages / enzyme-adapter-react-16 / src / ReactSixteenAdapter.js View on Github external
isCustomComponent(type) {
    const fakeElement = makeFakeElement(type);
    return !!type && (
      typeof type === 'function'
      || isForwardRef(fakeElement)
      || isContextProvider(fakeElement)
      || isContextConsumer(fakeElement)
      || isSuspense(fakeElement)
    );
  }
github airbnb / enzyme / packages / enzyme-adapter-react-16 / src / ReactSixteenAdapter.js View on Github external
isContextConsumer(type) {
    return !!type && isContextConsumer(makeFakeElement(type));
  }