从另一个类访问REACT ref

时间:2018-12-15 12:30:42

标签: reactjs ref renderer

在下面的myfile.jsx代码中

class ButtonRenderer extends React.Component {
constructor(props) {
        super(props);
      }
      I want to access myref which is created in main class from here
  }


extend default class main extends React.Component {   
     constructor(props) {
        super(props);
      }
    this.myref= react.createRef();       

   return

       render

              <input id="bla" type="text" ref={this.myref} />

}

我要访问从buttonrenderer类在主类中创建的ref

0 个答案:

没有答案