React TutorialLesson 19Free preview
React JSX Attributes
This lesson is part of React · All levels
Summary
Attributes on JSX elements are similar to HTML, but some names must be changed to be valid in JavaScript, for example class to className and for to htmlFor. The style attribute accepts JavaScript objects with the camelCase property, not CSS strings. Writing the attribute correctly makes React render elements without warning in console.
Key points
- Class written className and for written htmlFor
- String attribute values can be single quotes or double quotes
- Style is an object with the camelCase property, not a string
- Boolean attributes like disabled can be written without a value
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.