Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære JSX Specifying Attributes | Getting Started: JSX
Introduction to React
course content

Kursinnhold

Introduction to React

Introduction to React

1. Getting Started: ES6
2. Getting Started: JSX
3. React in Practice
4. React Components
5. Controlling Data & Content
6. Hooks
7. React Router

book
JSX Specifying Attributes

In order to specify attributes to the elements we can use the syntax: <element attribute=value></element>

It is very similar to HTML though it is important to note that the names of attributes are sometimes different and follow camelCase convention.

For example class in JSX is className instead, and tabindex is tabIndex.

js

We can also assign dynamic attributes by embedding an expression:

js

Note

We don't put quotes around curly braces when embedding a JavaScript expression in an attribute.

question mark

What is the correct way to specify the class attribute to a JSX element?

Select the correct answer

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 2. Kapittel 4

Spør AI

expand
ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

course content

Kursinnhold

Introduction to React

Introduction to React

1. Getting Started: ES6
2. Getting Started: JSX
3. React in Practice
4. React Components
5. Controlling Data & Content
6. Hooks
7. React Router

book
JSX Specifying Attributes

In order to specify attributes to the elements we can use the syntax: <element attribute=value></element>

It is very similar to HTML though it is important to note that the names of attributes are sometimes different and follow camelCase convention.

For example class in JSX is className instead, and tabindex is tabIndex.

js

We can also assign dynamic attributes by embedding an expression:

js

Note

We don't put quotes around curly braces when embedding a JavaScript expression in an attribute.

question mark

What is the correct way to specify the class attribute to a JSX element?

Select the correct answer

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 2. Kapittel 4
Vi beklager at noe gikk galt. Hva skjedde?
some-alt