Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
isCustomComponent(type) {
const fakeElement = makeFakeElement(type);
return !!type && (
typeof type === 'function'
|| isForwardRef(fakeElement)
|| isContextProvider(fakeElement)
|| isContextConsumer(fakeElement)
|| isSuspense(fakeElement)
);
}
const Provider = adapter.getProviderFromConsumer(el.type);
const value = providerValues.has(Provider)
? providerValues.get(Provider)
: getProviderDefaultValue(Provider);
const MockConsumer = Object.assign(
(props) => props.children(value),
el.type,
);
return withSetStateAllowed(() => renderer.render({ ...el, type: MockConsumer }));
} else {
isDOM = false;
let renderedEl = el;
if (isLazy(renderedEl)) {
throw TypeError('`React.lazy` is not supported by shallow rendering.');
}
if (isSuspense(renderedEl)) {
let { children } = renderedEl.props;
if (suspenseFallback) {
const { fallback } = renderedEl.props;
children = replaceLazyWithFallback(children, fallback);
}
const FakeSuspenseWrapper = () => children;
renderedEl = React.createElement(FakeSuspenseWrapper, null, children);
}
const { type: Component } = renderedEl;
const context = getMaskedContext(Component.contextTypes, unmaskedContext);
if (isMemo(el.type)) {
const { type: InnerComp, compare } = el.type;
return withSetStateAllowed(() => renderer.render(