How to use the inferno-shared.combineFrom function in inferno-shared

To help you get started, we’ve selected a few inferno-shared 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 infernojs / inferno / packages / inferno-redux / src / connect / connect.ts View on Github external
{
    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,
github infernojs / inferno / packages / inferno-router / src / StaticRouter.ts View on Github external
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
        }
      })
    );
  }
}
github infernojs / inferno / packages / inferno-router / src / match.ts View on Github external
}
          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
      };
    }
  }
}
github infernojs / inferno / packages / inferno-redux / src / components / connectAdvanced.ts View on Github external
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;
github infernojs / inferno / packages / inferno-clone-vnode / src / index.ts View on Github external
}

  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)
  );
}
github infernojs / inferno / packages / inferno-router / src / StaticRouter.ts View on Github external
function addBasename(basename, location) {
  if (!basename) {
    return location;
  }

  return combineFrom(location, { pathname: addLeadingSlash(basename) + location.pathname });
}
github infernojs / inferno / packages / inferno-server / src / renderToString.queuestream.ts View on Github external
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;
                }),
github infernojs / inferno / packages / inferno-redux / src / connect / mergeProps.ts View on Github external
export const defaultMergeProps = (stateProps, dispatchProps, ownProps) => {
  const merged = combineFrom(ownProps, stateProps);

  if (dispatchProps) {
    for (const key in dispatchProps) {
      merged[key] = dispatchProps[key];
    }
  }

  return merged;
};
github infernojs / inferno / packages / inferno-router / src / NavLink.ts View on Github external
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
      )
    );
  }