How to use the inferno.createComponentVNode function in inferno

To help you get started, we’ve selected a few inferno 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 insin / nwb / src / inferno / renderShim.js View on Github external
function renderEntry(exported) {
  if (exported.default) {
    exported = exported.default
  }
  // Assumptions: the entry module either renders the app itself or exports an
  // Inferno component (which is either a function or class) or VNode (which has
  // a flags property).
  if (Object.prototype.toString.call(exported) === '[object Function]') {
    vnode = Inferno.createComponentVNode(1 << 1 /* === VNodeFlags.ComponentUnknown */, exported)
  }
  else if (exported.flags) {
    vnode = exported
  }
  else {
    // Assumption: the entry module rendered the app
    return
  }
  Inferno.render(vnode, parent)
}
github infernojs / inferno / packages / inferno / __tests__ / state.spec.tsx View on Github external
it('setState should apply state during componentWillReceiveProps', done => {
      render(createComponentVNode(VNodeFlags.ComponentClass, TestCWRP, {}), container);
      expect(renderCount).toBe(1);

      render(
        createComponentVNode(VNodeFlags.ComponentClass, TestCWRP, {
          foo: 1
        }),
        container
      );
      expect(renderCount).toBe(2);
      done();
    });
  });
github infernojs / inferno / packages / inferno-compat / __tests__ / ReactClass.spec.jsx View on Github external
function renderIntoDocument(input) {
    return React.render(createComponentVNode(VNodeFlags.ComponentClass, Wrapper, { children: input }), container);
  }
github infernojs / inferno / packages / inferno-compat / __tests__ / ReactComponentLifeCycle.spec.jsx View on Github external
function renderIntoDocument(input) {
    return render(createComponentVNode(VNodeFlags.ComponentClass, Wrapper, { children: input }), container);
  }
github infernojs / inferno / packages / inferno-redux / src / components / connectAdvanced.ts View on Github external
public render() {
        const selector = this.selector;
        selector.shouldComponentUpdate = false;

        if (selector.error) {
          throw selector.error;
        } else {
          return normalizeProps(
            createComponentVNode(
              VNodeFlags.ComponentUnknown,
              WrappedComponent,
              this.addExtraProps(selector.props),
              null,
              withRef ? this.setWrappedInstance : null
            )
          );
        }
      }
    }
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 / 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
      )
    );
  }
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 / Switch.ts View on Github external
public render(): VNode | null {
    const { route } = this.context.router;
    const { children } = this.props;
    const location = this.props.location || route.location;

    if (isInvalid(children)) {
      return null;
    }

    const { match, _child } = extractMatchFromChildren(children, route, location);

    if (match) {
      return createComponentVNode(_child.flags, _child.type, combineFrom(_child.props, { location, computedMatch: match }));
    }

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

  return createComponentVNode(VNodeFlags.ComponentClass, Route, {
    children: linkComponent as any,
    exact,
    location: linkLocation,
    path: typeof to === 'object' ? to.pathname : to,
    strict
  });
}