Kintamųjų reikšmių įterpimo niuansai
Be konstantos įterpimo į tagą gali būti dar koks nors tekstas:
function App() {
const str = 'text';
return <div>
eee {str} bbb
</div>;
}
Į vieną tagą galima įterpti bet kokį skaičių konstantų:
function App() {
const str1 = 'text1';
const str2 = 'text2';
return <div>
{str1} {str2}
</div>;
}
Konstantų įterpimai taip pat gali būti atskirti kokiu nors tekstu:
function App() {
const str1 = 'text1';
const str2 = 'text2';
return <div>
{str1} eee {str2}
</div>;
}
Duotas toks kodas:
function App() {
const name = 'user';
const age = '30';
return <div>
name: ?
age: ?
</div>;
}
Įterpkite konstantą su vardu vietoje pirmojo
ženklo ?, o konstantą su amžiumi -
vietoje antrojo.