React에서 핵심 내용 이해하기📚
// ParentComponent.js
import React from 'react';
import ChildComponent from './ChildComponent';
const ParentComponent = props => {
return (
<div>
<h1>Parent Component</h1>
<ChildComponent />
</div>
);
}
export default ParentComponent;
부모는 자식을 품고 있다라고 생각하면 간단하게 이해할 수 있다.
// ParentComponent.js
import React from 'react';
import ChildComponent from './ChildComponent';
const ParentComponent = props => {
const name = 'John';
const age = 30;
return (
<div>
<ChildComponent name={name} age={age} />
</div>
);
}
export default ParentComponent;
// ChildComponent.js
import React from 'react';
const ChildComponent = props => {
return (
<div>
<p>Name: {props.name}</p> // 'John'
<p>Age: {props.age}</p> // 30
</div>
);
}
export default ChildComponent;
컴포넌트 내부에서 생기는 동적인 동작(클릭, 데이터 움직임 등)
import {useState} from 'react';
const User = props => {
const [username, setUsername] = useState('');
const usernameChangeHandler = event => {
setUsername(event.target.value);
console.log(username);
}
return (
<form>
<input id='username' type='text' onChange={usernameChangeHandler}/>
</form>
);
};
export default User
작지만 큰 핵심🆕
본 후기는 유데미-스나이퍼팩토리 10주 완성 프로젝트캠프 학습 일지 후기로 작성 되었습니다.
#프로젝트캠프 #프로젝트캠프후기 #유데미 #스나이퍼팩토리 #웅진씽크빅 #인사이드아웃 #IT개발캠프 #개발자부트캠프 #리액트 #react #부트캠프 #리액트캠프