© Adam Freeman 2019
Adam FreemanPro React 16https://doi.org/10.1007/978-1-4842-4451-7_16

16. Using Refs and Portals

Adam Freeman1 
(1)
London, UK
 

Under normal circumstances, a component doesn’t interact directly with the elements in the Document Object Model (DOM). Normal interaction is through props and event handlers, which make it possible to compose applications and for components to work together without knowledge of the content they deal with.

There are some situations where components need to interact with the elements in the DOM, and React provides two features for this purpose. The refs feature—short for references—provides access to the HTML elements rendered by a component after they have been added to the DOM. The portals feature provides ...

Get Pro React 16 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.