本文整理匯總了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';
}