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
.
const webLink = <a href="https://codefinity.com/">Codefinity</a>
We can also assign dynamic attributes by embedding an expression:
const element = <img src={user.avatarUrl}></img>;
Note
We don't put quotes around curly braces when embedding a JavaScript expression in an attribute.
Kiitos palautteestasi!
Kysy tekoälyä
Kysy tekoälyä
Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme
Kysy minulta kysymyksiä tästä aiheesta
Tiivistä tämä luku
Näytä käytännön esimerkkejä
Awesome!
Completion rate improved to 2.7
JSX Specifying Attributes
Pyyhkäise näyttääksesi valikon
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
.
const webLink = <a href="https://codefinity.com/">Codefinity</a>
We can also assign dynamic attributes by embedding an expression:
const element = <img src={user.avatarUrl}></img>;
Note
We don't put quotes around curly braces when embedding a JavaScript expression in an attribute.
Kiitos palautteestasi!