當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript react-dom.findDOMNode函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。