本文整理匯總了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;
}
示例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);
}
示例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;
});
示例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
示例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;
}
示例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 {