0 votes
in ReactJS by

Are custom DOM attributes supported in React v16?

1 Answer

0 votes
by

Yes. In the past, React used to ignore unknown DOM attributes. If you wrote JSX with an attribute that React doesn't recognize, React would just skip it.

For example, let's take a look at the below attribute:

<div mycustomattribute={'something'} />

Would render an empty div to the DOM with React v15:

<div />

In React v16 any unknown attributes will end up in the DOM:

<div mycustomattribute='something' />

This is useful for supplying browser-specific non-standard attributes, trying new DOM APIs, and integrating with opinionated third-party libraries.

Related questions

0 votes
asked Oct 31, 2023 in ReactJS by AdilsonLima
0 votes
asked Oct 28, 2023 in ReactJS by DavidAnderson
...