728x90
리액트 공식문서 학습기록
https://react.dev/learn
JavaScript in JSX with Curly Braces
위치
- JSX 태그내에 텍스트에 사용. ex)
<p>{text}</p>
- 기호 바로 뒤에 오는 속성. ex)
src={image}
이중
객체를 의미함. ex) {{'aa': 1}}
는 {'aa': 1}
객체임
인라인 스타일 프로퍼티는 카멜케이스
다시봐도 참…😡
ex) <ul style={{ backgroundColor: 'black' }}>
과제 1
const person = {
name: 'Gregorio Y. Zara',
theme: {
backgroundColor: 'black',
color: 'pink'
}
};
const TodoList = () => {
return (
<div style={person.theme}>
<h1>{person.name}'s Todos</h1>
<img
className="avatar"
src="https://i.imgur.com/7vQD0fPs.jpg"
alt="Gregorio Y. Zara"
/>
<ul>
<li>Improve the videophone</li>
<li>Prepare aeronautics lectures</li>
<li>Work on the alcohol-fuelled engine</li>
</ul>
</div>
);
}
export default TodoList;
과제 2
const person = {
name: 'Gregorio Y. Zara',
theme: {
backgroundColor: 'black',
color: 'pink'
},
image: 'https://i.imgur.com/7vQD0fPs.jpg'
};
const TodoList = () => {
return (
<div style={person.theme}>
<h1>{person.name}'s Todos</h1>
<img
className="avatar"
src={person.image}
alt="Gregorio Y. Zara"
/>
<ul>
<li>Improve the videophone</li>
<li>Prepare aeronautics lectures</li>
<li>Work on the alcohol-fuelled engine</li>
</ul>
</div>
);
}
export default TodoList;
과제 3
const baseUrl = 'https://i.imgur.com/';
const person = {
name: 'Gregorio Y. Zara',
imageId: '7vQD0fP',
imageSize: 's',
theme: {
backgroundColor: 'black',
color: 'pink'
}
};
const TodoList = () => {
return (
<div style={person.theme}>
<h1>{person.name}'s Todos</h1>
<img
className="avatar"
src={baseUrl + person.imageId + person.imageSize+'.jpg'}
alt={person.name}
/>
<ul>
<li>Improve the videophone</li>
<li>Prepare aeronautics lectures</li>
<li>Work on the alcohol-fuelled engine</li>
</ul>
</div>
);
}
export default TodoList;
'공부공부 > React' 카테고리의 다른 글
[react 공식문서] 06 Conditional Rendering (0) | 2024.02.13 |
---|---|
[react 공식문서] 05 Passing Props to a Component (1) | 2024.02.13 |
[react 공식문서] 03 Writing Markup with JSX (1) | 2024.02.13 |
[react 공식문서] 02 Importing and Exporting Components (0) | 2024.02.13 |
[react 공식문서] 01 Your first component (0) | 2023.10.16 |