Pass React Ref from parent to child in order to get DOM element
问题 I have a parent and a child component. I need to access the parent's HTMLelement in the child component. I have a working but unclean solution involving this.setState({ domNode: ReactDOM.findDOMNode(this) }); in the parent's componentDidMount which is just wrong on many levels. How can i do this using createRef() in the parent to pass its ref as a prop to the child and then how do i get the DOM node with type HTMLElement from the ref? 回答1: The best solution that doesn't involve any hack would