Monday, 14 May, 2018 UTC

Summary

JSX is an amazing pseudo-language for React, and if I’m honest, it’s what brought me to love React so much. Using React without JSX is cumbersome and frustrating, while using JSX is such an easier way to express your code. One drawback of JSX, however, is that it makes accessing component elements indirect, if not difficult.

The truth is that accessing a component’s own elements is actually much easier than most think. Let’s look at how a component method can access its own DOM node with JavaScript:

Method 1: react-dom

react-dom provides a findDomNode method for finding the component’s node: