本文整理汇总了TypeScript中react-test-renderer.create函数的典型用法代码示例。如果您正苦于以下问题:TypeScript create函数的具体用法?TypeScript create怎么用?TypeScript create使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: require
import React = require("react");
import { act, create, ReactTestInstance } from "react-test-renderer";
import { createRenderer } from 'react-test-renderer/shallow';
class TestComponent extends React.Component { }
const renderer = create(React.createElement("div"), {
createNodeMock: (el: React.ReactElement<any>) => {
return {};
}
});
const json = renderer.toJSON();
if (json) {
json.type = "t";
json.props = {
prop1: "p",
};
json.children = [json];
}
const tree = renderer.toTree();
if (tree) {
tree.type = "t";
tree.props = {
prop1: "p",
};
tree.children = [tree];
tree.rendered = tree;
tree.nodeType = "component";
tree.nodeType = "host";
开发者ID:SaschaNaz,项目名称:DefinitelyTyped,代码行数:31,代码来源:react-test-renderer-tests.ts
示例2: create
import * as React from "react";
import { create } from "react-test-renderer";
import { createRenderer } from 'react-test-renderer/shallow';
const tree = create(React.createElement("div"), {
createNodeMock: (el: React.ReactElement<any>) => {
return {};
}
}).toJSON();
tree.type = "t";
tree.props = {
prop1: "p",
};
tree.children = [tree];
tree.$$typeof = "t";
class TestComponent extends React.Component { }
const component = React.createElement(TestComponent);
const shallowRenderer = createRenderer();
shallowRenderer.render(component);
shallowRenderer.getRenderOutput();
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:23,代码来源:react-test-renderer-tests.ts
示例3: callback
export function safeCreate<TProps>(content: React.ReactElement<TProps>, callback: (wrapper: renderer.ReactTestRenderer) => void): void {
const wrapper = renderer.create(content);
callback(wrapper);
wrapper.unmount();
}
开发者ID:OfficeDev,项目名称:office-ui-fabric-react,代码行数:6,代码来源:safeCreate.ts
注:本文中的react-test-renderer.create函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论