Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React JSX Invalid ARIA attribute `ariaLabel`

react jsx:

<button ariaLabel='label'>click</button>

rendered html:

<button arialabel="label">click</button>

console warning:

index.js:1 Warning: Invalid ARIA attribute `ariaLabel`. Did you mean `aria-label`?

ummm no, I meant ariaLabel since we always camelCase in jsx. Why is it all lowercase in the rendered html?

like image 874
Nick Carbone Avatar asked Sep 13 '25 11:09

Nick Carbone


1 Answers

This seems to be an exception to the rule. Look at the documentation here -- Official React Docs

Note that all aria-* HTML attributes are fully supported in JSX. Whereas most DOM properties and attributes in React are camelCased, these attributes should be hyphen-cased (also known as kebab-case, lisp-case, etc) as they are in plain HTML:

like image 184
rudolph schmitz Avatar answered Sep 15 '25 02:09

rudolph schmitz