변수 값 삽입 시 주의사항
태그 안에 상수를 삽입하는 것 외에도 다른 텍스트가 있을 수 있습니다:
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>;
}
첫 번째 기호 ? 대신 이름 상수를,
두 번째 기호 대신 나이 상수를 삽입하세요.