React JSX Attributes

How to use attributes in JSX.

React JSX Attributes

Attributes in JSX work similar to HTML attributes, but with some differences.

Since JSX is closer to JavaScript than to HTML, React DOM uses camelCase property naming convention instead of HTML attribute names.

For example, class becomes className in JSX, and tabindex becomes tabIndex.

Example

const element = <img src={user.avatarUrl} className="avatar" />;