本文整理汇总了TypeScript中react-dom.findDOMNode函数的典型用法代码示例。如果您正苦于以下问题:TypeScript findDOMNode函数的具体用法?TypeScript findDOMNode怎么用?TypeScript findDOMNode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了findDOMNode函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: it
it('find dom node', () => {
const rootElement = document.createElement('div');
ReactDOM.render(React.createElement('div'), rootElement);
ReactDOM.findDOMNode(rootElement);
ReactDOM.findDOMNode(null);
ReactDOM.findDOMNode(undefined);
});
开发者ID:CNBoland,项目名称:DefinitelyTyped,代码行数:7,代码来源:react-dom-tests.ts
示例2: keyHandler
export function keyHandler(index: number, position: string, refsCollection: any[], kids: any[], custom = false) {
if (!Array.isArray(kids)) {
return;
}
let nextIndex;
if (position === 'up') {
if (index === 0) {
// loop back to end
nextIndex = kids.length - 1;
} else {
nextIndex = index - 1;
}
} else if (index === kids.length - 1) {
// loop back to beginning
nextIndex = 0;
} else {
nextIndex = index + 1;
}
if (refsCollection[nextIndex] === null) {
keyHandler(nextIndex, position, refsCollection, kids, custom);
} else if (custom) {
if (refsCollection[nextIndex].focus) {
refsCollection[nextIndex].focus()
}
const element = ReactDOM.findDOMNode(refsCollection[nextIndex]) as HTMLElement;
element.focus()
}
else {
refsCollection[nextIndex].focus();
}
}
开发者ID:LHinson,项目名称:patternfly-org,代码行数:31,代码来源:util.ts
示例3: _onDrag
_onDrag(){
let e:any = d3.event,
t = e.translate,
z = e.scale,
el = ReactDOM.findDOMNode(this.props.children as SVGGElement);
d3.select(el)
.attr('transform','translate('+t+')');
}
开发者ID:suhdev,项目名称:react-draggable,代码行数:8,代码来源:SVGDraggable.ts
示例4: enableTypeaheadFeatures
export function enableTypeaheadFeatures(typeahead: any, name: string, required: boolean) {
const typeaheadInput =
ReactDOM.findDOMNode(typeahead.getInstance()).querySelector(`input[name=${name}]`)
typeaheadInput.setAttribute('id', name)
if (required) {
typeaheadInput.setAttribute('required', 'true')
}
}
开发者ID:haimich,项目名称:billy,代码行数:9,代码来源:forms.ts
示例5: isMounted
export function isMounted(component: React.ReactInstance) {
try {
ReactDOM.findDOMNode(component);
return true;
} catch (e) {
// Error: Invariant Violation: Component (with keys: props,context,state,refs,_reactInternalInstance) contains `render` method but is not mounted in the DOM
return false;
}
}
开发者ID:snippetmodule,项目名称:docs-search-client,代码行数:9,代码来源:react-utils.ts
示例6: show
public show(data) {
this.setState({
title: data.title,
startDate: data.startDate,
endDate: data.endDate,
duration: data.duration,
description: data.description
});
const item = DOM.findDOMNode(this) as any;
item.style.display = 'flex';
}
开发者ID:ConstYavorskiy,项目名称:HeractJS,代码行数:11,代码来源:ModalWindow.ts
示例7: return
export const hasClass = (inst, className)=> {
if(ReactTestUtils.isDOMComponent(inst.node)) {
return inst.hasClass(className)
} else {
try {
let classes = ReactDOM.findDOMNode(inst.node).className
return (' ' + classes + ' ').indexOf(' ' + className + ' ') > -1
} catch (e){}
}
return false
}
开发者ID:BenJamesbabala,项目名称:searchkit,代码行数:11,代码来源:TestHelpers.ts
示例8: it
it('Simulate', () => {
const element = document.createElement('div');
const dom = ReactDOM.render(
React.createElement('input', { type: 'text' }),
element
) as Element;
const node = ReactDOM.findDOMNode(dom) as HTMLInputElement;
node.value = 'giraffe';
ReactTestUtils.Simulate.change(node);
ReactTestUtils.Simulate.keyDown(node, { key: "Enter", keyCode: 13, which: 13 });
});
开发者ID:Crevil,项目名称:DefinitelyTyped,代码行数:12,代码来源:react-dom-tests.ts
示例9: fitHeaderText
export function fitHeaderText(maxFontHeight, minFontHeight, component, className: any) {
const node = ReactDOM.findDOMNode(component);
let headerNode = node.getElementsByClassName(className)[0];
headerNode.childNodes.forEach(node => {
fitty(node, {
maxSize: maxFontHeight,
minSize: minFontHeight,
multiLine: true
})
})
}
开发者ID:robertfmurdock,项目名称:Coupling,代码行数:12,代码来源:ReactFittyHelper.ts
示例10: show
public show(data: any) {
this.setState({
left: data.left,
top: data.top,
title: data.title,
startDate: data.startDate,
endDate: data.endDate,
duration: data.duration,
description: data.description
});
const item = DOM.findDOMNode(this) as any;
item.style.display = 'block';
}
开发者ID:ConstYavorskiy,项目名称:HeractJS,代码行数:13,代码来源:ActionChartPopup.ts
注:本文中的react-dom.findDOMNode函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论