React PropTypes DOM element?

mpen picture mpen · Sep 9, 2016 · Viewed 18.9k times · Source

How do I mark a property as having to be a DOM element?

This page says that PropTypes.element is actually a React element, so what's the equivalent for DOM element?

Answer

Gregory Bolkenstijn picture Gregory Bolkenstijn · Jun 21, 2018
PropTypes.instanceOf(Element)

Is working for me. You can also add isRequired:

PropTypes.instanceOf(Element).isRequired