Skip to content

React findDOMNode()

ythy edited this page Nov 1, 2017 · 1 revision

ReactDom.findDOMNode() 目前返回的类型是 Element, 但是程序需要HTMLElement 来进行.click() 这样的操作

处理方式: 参考 How to focus DOM Node after using ReactDOM.findDOMNode

playSound() {
  const el = ReactDOM.findDOMNode(this);
  if (el && el instanceof HTMLMediaElement) {
    el.play();
  }
}
Clone this wiki locally