चर मान डालने में बारीकियां
टैग में एक स्थिरांक डालने के अलावा कोई और पाठ भी हो सकता है:
function App() {
const str = 'text';
return <div>
eee {str} bbb
</div>;
}
एक टैग में जितने चाहें उतने स्थिरांक डाले जा सकते हैं:
function App() {
const str1 = 'text1';
const str2 = 'text2';
return <div>
{str1} {str2}
</div>;
}
स्थिरांक डालने को किसी पाठ द्वारा भी अलग किया जा सकता है:
function App() {
const str1 = 'text1';
const str2 = 'text2';
return <div>
{str1} eee {str2}
</div>;
}
निम्नलिखित कोड दिया गया है:
function App() {
const name = 'user';
const age = '30';
return <div>
name: ?
age: ?
</div>;
}
पहले चिह्न ? के स्थान पर नाम वाला स्थिरांक डालें,
और आयु वाला स्थिरांक - दूसरे के स्थान पर डालें।