Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- while
- mysql
- CSS
- web
- system
- Algorithm
- data structure
- XML
- for
- react
- php
- Pipelining
- html
- python
- DB
- DS
- MIPS
- architecture
- DoM
- instruction
- Java
- javascript
- Class
- function
- Linux
- computer
- DATAPATH
- github
- control
- MacOS
Archives
- Today
- Total
YYYEJI
[React] 함수형 컴포넌트에 props 전달하기 본문
728x90
props는
속성을 나타내는 데이터입니다.
props를 인자 값으로 받는 함수형 컴포넌트를 하나 만들어 줍니다.
function Component(props) {
if (props.value===10) {
return <p>The number is 10.</p>;
}
return null;
}
props.value에서 value는 속성 이름입니다.
아래 코드에서 value 속성에 값을 할당시켜 줍니다.
function Question() {
const [counter, setCounter] = React.useState(1);
return (
<Component value={counter} />
);
}
counter의 값이 1이기 때문에 return 값은 null이 되지만, 초기값을 9로 바꿔주면 return 값이 생깁니다.
◡̈
'Web Application Server (WAS)' 카테고리의 다른 글
[React] 리액트(React)에서 텍스트 줄바꿈하기 (0) | 2023.01.14 |
---|---|
[React] Link 컴포넌트 밑줄 제거하기 (0) | 2023.01.14 |
[JSP] Cannot resolve taglib with uri http://java.sun.com/jsp/jstl/core 에러 (0) | 2023.01.11 |
[React] Failed to load plugin 'jest' declared in 'package.json 에러 (0) | 2023.01.11 |
[API KEY] 카카오 API 키 발급 받는 방법 (0) | 2023.01.11 |