https://stackoverflow.com/questions/37949981/call-child-method-from-parent
ref
使って、
<Child ref={this.child} />
current.メソッド名()
で呼べる。
this.child.current.getAlert();
そのままだとundefined
になる??
コンストラクタでReact.createRef();が必須かも
constructor(props) { super(props); this.myRef = React.createRef(); }
https://reactjs.org/docs/refs-and-the-dom.html
TypeScriptでメンバ変数はany
が嫌なとき、
private child: React.RefObject<Child>;
React.RefObject<Child>
のジェネリックで変数の型つけられる。