Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
{
pure = true,
areStatesEqual = strictEqual,
areOwnPropsEqual = shallowEqual,
areStatePropsEqual = shallowEqual,
areMergedPropsEqual = shallowEqual,
...extraOptions
} = {}
) => {
const initMapStateToProps = match(mapStateToProps, mapStateToPropsFactories, 'mapStateToProps');
const initMapDispatchToProps = match(mapDispatchToProps, mapDispatchToPropsFactories, 'mapDispatchToProps');
const initMergeProps = match(mergeProps, mergePropsFactories, 'mergeProps');
return connectHOC(
selectorFactory as any,
combineFrom(
{
// used in error messages
methodName: 'connect',
// used to compute Connect's displayName from the wrapped component's displayName.
// tslint:disable-next-line:object-literal-sort-keys
getDisplayName: name => `Connect(${name})`,
// if mapStateToProps is falsy, the Connect component doesn't subscribe to store state changes
shouldHandleStateChanges: !!mapStateToProps,
// passed through to selectorFactory
areMergedPropsEqual,
areOwnPropsEqual,
areStatePropsEqual,
areStatesEqual,
public render({ basename, context, location, ...props }): VNode {
return createComponentVNode(
VNodeFlags.ComponentClass,
Router,
combineFrom(props, {
history: {
action: 'POP',
block: this.handleBlock,
createHref: this.createHref,
go: staticHandler('go'),
goBack: staticHandler('goBack'),
goForward: staticHandler('goForward'),
listen: this.handleListen,
location: stripBasename(basename, createLocation(location)),
push: this.handlePush,
replace: this.handleReplace
}
})
);
}
}
}
if (matchChild.matched) {
children = matchChild.matched;
const childProps = children.props.params;
for (const key in childProps) {
params[key] = childProps[key];
}
}
} else {
children = null;
}
}
const matched = Inferno.cloneVNode(route, {
children,
params: combineFrom(params, matchBase.params)
});
return {
location,
matched,
redirect
};
}
}
}
const wrapWithConnect = (WrappedComponent: T): T => {
invariant(
typeof WrappedComponent === 'function',
`You must pass a component to the function returned by ` + `connect. Instead received ${WrappedComponent}`
);
const wrappedComponentName: string = (WrappedComponent as any).displayName || WrappedComponent.name || 'Component';
const displayName = getDisplayName(wrappedComponentName);
const selectorFactoryOptions: IConnectOptions = combineFrom(connectOptions, {
WrappedComponent,
displayName,
getDisplayName,
methodName,
renderCountProp,
shouldHandleStateChanges,
storeKey,
withRef,
wrappedComponentName
}) as any;
class Connect extends Component {
public static displayName = displayName;
public static WrappedComponent = WrappedComponent;
public version: number;
}
if (childLen === 1) {
children = _children;
} else if (childLen > 1) {
children = [];
while (childLen-- > 0) {
children[childLen] = arguments[childLen + 2];
}
}
props.children = children;
if (flags & VNodeFlags.Component) {
return createComponentVNode(flags, vNodeToClone.type, !vNodeToClone.props && !props ? EMPTY_OBJ : combineFrom(vNodeToClone.props, props), key, ref);
}
if (flags & VNodeFlags.Text) {
return createTextVNode(children);
}
if (flags & VNodeFlags.Fragment) {
return createFragment(childLen === 1 ? [children] : children, ChildFlags.UnknownChildren, key);
}
return normalizeProps(
createVNode(flags, vNodeToClone.type, className, null, ChildFlags.HasInvalidChildren, combineFrom(vNodeToClone.props, props), key, ref)
);
}
function addBasename(basename, location) {
if (!basename) {
return location;
}
return combineFrom(location, { pathname: addLeadingSlash(basename) + location.pathname });
}
initialProps.then(dataForContext => {
if (typeof dataForContext === 'object') {
instance.props = combineFrom(instance.props, dataForContext);
}
const renderOut = instance.render(instance.props, instance.state, instance.context);
if (isInvalid(renderOut)) {
this.addToQueue('', promisePosition);
} else if (isString(renderOut)) {
this.addToQueue(escapeText(renderOut), promisePosition);
} else if (isNumber(renderOut)) {
this.addToQueue(renderOut + '', promisePosition);
} else {
this.renderVNodeToQueue(renderOut, instance.context, promisePosition);
}
setTimeout(this.pushQueue, 0);
return promisePosition;
}),
export const defaultMergeProps = (stateProps, dispatchProps, ownProps) => {
const merged = combineFrom(ownProps, stateProps);
if (dispatchProps) {
for (const key in dispatchProps) {
merged[key] = dispatchProps[key];
}
}
return merged;
};
function linkComponent({ location, match }): VNode {
const isActive = !!(getIsActive ? getIsActive(match, location) : match);
return createComponentVNode(
VNodeFlags.ComponentFunction,
Link,
combineFrom(
{
'aria-current': isActive && ariaCurrent,
className: isActive ? [className, activeClassName].filter(filter).join(' ') : className,
onClick,
style: isActive ? combineFrom(style, activeStyle) : style,
to
},
rest
)
);
}