如何访问父项中的子项的引用以在父函数中对它们执行某些操作?
class Parent extends Component {
someFunction(){
// how to access h1 element of child in here ??
}
render() {
return (
<Child />
);
}
}
class Child extends Component {
render() {
return (
<h1 ref="hello">Hello</h1>
);
}
}
Run Code Online (Sandbox Code Playgroud)