12. Accessing DOM Elements

There will be times when you want to access properties and methods on an HTML element directly. In our React-colored world where JSX represents everything that is good and pure about markup, why would you ever want to deal directly with the horribleness that is HTML? As you will find out (if you haven’t already), there are many cases where dealing with HTML elements through the JavaScript DOM API directly is easier than fiddling with “the React way” of doing things.

To highlight one such situation, take a look at the Colorizer example in Figure 12-1.

Image

Figure 12-1 Colorizer example.

If you have access to a browser, you ...

Get Learning React 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.