• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript inferno-shared.warning函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中inferno-shared.warning函数的典型用法代码示例。如果您正苦于以下问题:TypeScript warning函数的具体用法?TypeScript warning怎么用?TypeScript warning使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了warning函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: scuMobx

function scuMobx(nextProps, nextState) {
  if (isUsingStaticRendering) {
    warning(
      "[inferno-mobx] It seems that a re-rendering of a React component is triggered while in static (server-side) mode. Please make sure components are rendered only once server-side."
    );
  }

  // Update on any state changes (as is the default)
  if (this.state !== nextState) {
    return true;
  }

  // Update if props are shallowly not equal, inspired by PureRenderMixin
  const keys = Object.keys(this.props);
  if (keys.length !== Object.keys(nextProps).length) {
    return true;
  }

  for (let i = keys.length - 1; i >= 0; i--) {
    const key = keys[i];
    const newValue = nextProps[key];
    if (newValue !== this.props[key]) {
      return true;
    } else if (
      newValue &&
      typeof newValue === "object" &&
      !isObservable(newValue)
    ) {
      // If the newValue is still the same object, but that object is not observable,
      // fallback to the default behavior: update, because the object *might* have changed.
      return true;
    }
  }
  return false;
}
开发者ID:russelgal,项目名称:inferno,代码行数:35,代码来源:makeReactive.ts


示例2: Link

export default function Link(props, { router }): VNode {
  const {
    activeClassName,
    activeStyle,
    className,
    onClick,
    children,
    to,
    ...otherProps
  } = props;

  let classNm;
  if (className) {
    classNm = className as string;
  }

  if (!router) {
    if (process.env.NODE_ENV !== "production") {
      warning(
        "<Link/> component used outside of <Router/>. Fallback to <a> tag."
      );
    }

    otherProps.href = to;
    otherProps.onClick = onClick;

    return renderLink(classNm, children, otherProps);
  }

  otherProps.href = isBrowser
    ? router.createHref({ pathname: to })
    : router.location.baseUrl ? router.location.baseUrl + to : to;

  if (router.location.pathname === to) {
    if (activeClassName) {
      classNm = (className ? className + " " : "") + activeClassName;
    }
    if (activeStyle) {
      otherProps.style = combineFrom(props.style, activeStyle);
    }
  }

  otherProps.onclick = function navigate(e) {
    if (e.button !== 0 || e.ctrlKey || e.altKey || e.metaKey || e.shiftKey) {
      return;
    }
    e.preventDefault();
    if (typeof onClick === "function") {
      onClick(e);
    }
    router.push(to, e.target.textContent);
  };

  return renderLink(classNm, children, otherProps);
}
开发者ID:russelgal,项目名称:inferno,代码行数:55,代码来源:Link.ts


示例3: warning

      keyValues.some(function(item, idx) {
        const hasDuplicate = keyValues.indexOf(item) !== idx;

        if (hasDuplicate) {
          warning(
            "Inferno normalisation(...): Encountered two children with same key, all keys must be unique within its siblings. Duplicated key is:" +
              item
          );
        }

        return hasDuplicate;
      });
开发者ID:russelgal,项目名称:inferno,代码行数:12,代码来源:normalization.ts


示例4: removeRoot

  return root;
}

function removeRoot(root: Root): void {
  for (let i = 0, len = roots.length; i < len; i++) {
    if (roots[i] === root) {
      roots.splice(i, 1);
      return;
    }
  }
}

if (process.env.NODE_ENV !== "production") {
  if (isBrowser && document.body === null) {
    warning(
      'Inferno warning: you cannot initialize inferno without "document.body". Wait on "DOMContentLoaded" event, add script to bottom of body, or use async/defer attributes on script tag.'
    );
  }
}

const documentBody = isBrowser ? document.body : null;
/**
 * Renders virtual node tree into parent node.
 * @param {VNode | null | string | number} input vNode to be rendered
 * @param parentDom DOM node which content will be replaced by virtual node
 * @returns {InfernoChildren} rendered virtual node
 */
export function render(
  input: InfernoInput,
  parentDom:
    | Element
开发者ID:russelgal,项目名称:inferno,代码行数:31,代码来源:rendering.ts


示例5: hydrateElement

function hydrateElement(
  vNode: VNode,
  dom: Element,
  lifecycle: LifecycleClass,
  context: Object,
  isSVG: boolean
): Element {
  const children = vNode.children;
  const props = vNode.props;
  const className = vNode.className;
  const flags = vNode.flags;
  const ref = vNode.ref;

  isSVG = isSVG || (flags & VNodeFlags.SvgElement) > 0;
  if (dom.nodeType !== 1 || dom.tagName.toLowerCase() !== vNode.type) {
    if (process.env.NODE_ENV !== "production") {
      warning(
        "Inferno hydration: Server-side markup doesn't match client-side markup or Initial render target is not empty"
      );
    }
    const newDom = mountElement(vNode, null, lifecycle, context, isSVG);

    vNode.dom = newDom;
    replaceChild(dom.parentNode, newDom, dom);
    return newDom as Element;
  }
  vNode.dom = dom;
  if (!isInvalid(children)) {
    hydrateChildren(children, dom, lifecycle, context, isSVG);
  } else if (dom.firstChild !== null && !isSamePropsInnerHTML(dom, props)) {
    dom.textContent = ""; // dom has content, but VNode has no children remove everything from DOM
  }
  if (props) {
    let hasControlledValue = false;
    const isFormElement = (flags & VNodeFlags.FormElement) > 0;
    if (isFormElement) {
      hasControlledValue = isControlledFormElement(props);
    }
    for (const prop in props) {
      // do not add a hasOwnProperty check here, it affects performance
      patchProp(prop, null, props[prop], dom, isSVG, hasControlledValue);
    }
    if (isFormElement) {
      processElement(flags, vNode, dom, props, true, hasControlledValue);
    }
  }
  if (!isNullOrUndef(className)) {
    if (isSVG) {
      dom.setAttribute("class", className);
    } else {
      dom.className = className;
    }
  } else {
    if (dom.className !== "") {
      dom.removeAttribute("class");
    }
  }
  if (ref) {
    mountRef(dom, ref, lifecycle);
  }
  return dom;
}
开发者ID:russelgal,项目名称:inferno,代码行数:62,代码来源:hydration.ts


示例6: testFn

  createRenderer,
  findDOMNode,
  render
} from "./DOM/rendering";
import { EMPTY_OBJ } from "./DOM/utils";

if (process.env.NODE_ENV !== "production") {
  /* tslint:disable-next-line:no-empty */
  const testFunc = function testFn() {};
  if (
    ((testFunc as Function).name || testFunc.toString()).indexOf("testFn") ===
    -1
  ) {
    warning(
      "It looks like you're using a minified copy of the development build " +
        "of Inferno. When deploying Inferno apps to production, make sure to use " +
        "the production build which skips development warnings and is faster. " +
        "See http://infernojs.org for more details."
    );
  }
}

// To please the TS God
// https://github.com/Microsoft/TypeScript/issues/6307
export declare const VNodeFlags: _VNodeFlags;
export declare const Root: _Root;
export declare const LifecycleClass: _LifecycleClass;

const version = process.env.INFERNO_VERSION;

// we duplicate it so it plays nicely with different module loading systems
export default {
开发者ID:russelgal,项目名称:inferno,代码行数:32,代码来源:index.ts



注:本文中的inferno-shared.warning函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript inflection.pluralize函数代码示例发布时间:2022-05-25
下一篇:
TypeScript inferno-shared.throwError函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap