本文整理汇总了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);
});
示例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();
}
}
示例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+')');
}
示例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')
}
}
示例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;
}
}
示例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';
}
示例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
}
示例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 });
});
示例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
})
})
}
示例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';
}