Refs
"I think we have used this before," asked Shawn.
"Yeah. What refs do is give us a handle to refer to some part of the component. We have done this in forms. Here, we are using it to get a handle to the modal so that we can invoke the modal() method on top of it."
"This would, in turn, display the modal."
"Now, notice how we are using the getDOMNode() method."
"Yup. What does it do?"
"The getDOMNode() method helps us to get the underlying DOM node, where the React element is rendered. In our case, we want to invoke a method on the DOM node."
"When we call this.refs.timeoutModal, it returns us a ref object of the component."
"This is different from the actual DOM component. It's actually a React-wrapped object. To grab the underlying DOM object, we ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access