Inserting variables and constants into tag attributes in JSX
Variables and constants can be inserted not only into tag texts, but also into attributes. In this case, quotation marks are not placed around attributes:
jsxfunction App() {
const str = 'elem';
return <div id={str}>
text
</div>;
}
The result of running this code will be the following:
html<div id="elem">
text
</div>
Задание 1
The following code is given:
jsxfunction App() {
const attr = 'block';
return <div>
text
</div>;
}
Insert the value of the constant attr into the id attribute of our div.