React๋?
javascript ๋ผ์ด๋ธ๋ฌ๋ฆฌ
React ํ์ผ๋ค์ ์ญํ
index.js
- src ํด๋์ ํฌํจ
- ๋ฉ์ธ ํ๋ก๊ทธ๋จ
- HTML ํ ํ๋ฆฟ ๋ฐ JavaScript์ ์ปดํฌ๋ํธ๋ฅผ ์กฐํฉํ๊ณ ๋ ๋๋งํด ์ค์ ํ์
App.js
- src ํด๋์ ํฌํจ
- ์ปดํฌ๋ํธ๋ฅผ ์ ์ํ๋ ํ๋ก๊ทธ๋จ
- ์ค์ ๋ก ํ๋ฉด์ ํ์๋๋ ๋ด์ฉ๋ฑ์ด ์ ์
index.html
- public ํด๋์ ์์
- ๋ฉ์ธ ํ๋ก๊ทธ๋จ์ธ index.js์ ๋์๋๋ ๊ฒ
- HTML ํ ํ๋ฆฟ ํ์ผ
- ์ง์ ํ์๋๋ ๊ฒ์ ์๋๊ณ , index.js์ ์ํด ์ผ์ด๋ ๋ ๋๋ง ๊ฒฐ๊ณผ๊ฐ ํ์๋จ
React Life Cycle
React lifecycle ์ฉ์ด
์ฉ์ด ์ค๋ช
~ will | ์ด๋ค ์์ ์ ์ํํ๊ธฐ ์ ์ ์คํ๋๋ ๋ฉ์๋์ ๊ด๋ จ๋ ์ฉ์ด |
~ did | ์ด๋ค ์์ ์ ์ํํ ์ดํ์ ์คํ๋๋ ๋ฉ์๋์ ๊ด๋ จ๋ ์ฉ์ด |
mount | ์ปดํฌ๋ํธ ๋ด์์ DOM์ด ์์ฑ๋๊ณ ์น ๋ธ๋ผ์ฐ์ ์์ ๋ํ๋ ๋ฉ์๋์ ๊ด๋ จ๋ ์ฉ์ด |
unmount | ์ปดํฌ๋ํธ ๋ด์์ DOM์ ์ ๊ฑฐํ๋ ๋ฉ์๋์ ๊ด๋ จ๋ ์ฉ์ด |
update | ์ปดํฌ๋ํธ ๋ด์์ ๋ณํ๊ฐ ๋ฐ์ํ์์๋ ์ํํ๋๊ฒ์ ์๋ฏธ |
ex) props, state, ๋ถ๋ชจ ์ปดํฌ๋ํธ์ ๋ฆฌ ๋ ๋๋ง, | |
forceUpdate๋ฅผ ํตํด ๊ฐ์ ๋ก ๋ณ๊ฒฝํ๋ ๊ฒฝ์ฐ |
๐ก ์๋ช ์ฃผ๊ธฐ ์์
- ์ปดํฌ๋ํธ์ ์คํ
- constructor() ์คํ
- render() ์คํ
- ComponentDidMount() ์คํ
์กฐ๊ฑด๋ถ ์ํ
- ์ปดํฌ๋ํธ ๋ด์ ๋ณํ๊ฐ ์์ ๋ : componentDidUpdate() ์คํ
- ์ปดํฌ๋ํธ์ ์๋ฉธ์ด ์ํ๋์์ ๋ : componentWillUnmount() ์คํ
1. Mounting - constructor()
๐ก ์ปดํฌ๋ํธ๊ฐ ์๋ก ์์ฑ์ด ๋๊ณ ๋ ๋๋ง(DOM ์์ฑ) ์ด์ ์ ์ํ์ด ๋๋ ํด๋์ค ์์ฑ์ ๋ฉ์๋๋ฅผ ์๋ฏธ
- ์์ฑํ ํจ์๋ฅผ ๋ฐ์ธ๋ฉ ํ ๋ ์ฌ์ฉ
- state ๊ณต๊ฐ์ ๋ณ์ ๊ฐ์ ์ด๊ธฐํํ ๋ ์ฌ์ฉ
2. Mounting - render()
๐ก ๋ฏธ๋ฆฌ ๊ตฌํํ HTML๋ฅผ ํ๋ฉด์์ ๋ณด์ฌ์ฃผ๋ ๋ฉ์๋
- ํด๋น ๋ฉ์๋ ์์์๋ ๋ถ๋ชจ ์ปดํฌ๋ํธ๋ก ์ ๋ฌ๋ฐ์ props ๊ฐ์ ์ ๊ทผ์ด ๊ฐ๋ฅ
- constructor()์์ ์ ์ํ state ๊ฐ์ ์ ๊ทผ์ด ๊ฐ๋ฅ
- ํด๋น ๊ณต๊ฐ์์๋ setState() ์ฌ์ฉ ๋ถ๊ฐ
3. Mounting - ComponentDidMount()
๐ก ์ปดํฌ๋ํธ ๋ด์์ ๋ ๋๋ง์ด ์ํ๋ ์ดํ์ ์คํ์ด ๋๋ ๋ฉ์๋
- ์๋ฐ์คํฌ๋ฆฝํธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๋๋ ํ๋ ์์ํฌ์ ํจ์๋ฅผ ํธ์ถํ๊ฑฐ๋ ์ด๋ฒคํธ ๋ฑ๋ก์ ์ฌ์ฉ
- setTimeout, setInterval, ๋คํธ์ํฌ ์์ฒญ ๊ฐ์ ๋น๋๊ธฐ ์์ ์ ์ฒ๋ฆฌํ ๋ ์ฌ์ฉ
4. Updating - componentDidUpdate()
๐ก ์ปดํฌ๋ํธ ๋ด์์ ๋ณํ๊ฐ ๋ฐ์ํ์์ ๊ฒฝ์ฐ์ ์คํ๋๋ ๋ฉ์๋
- ๋ณํ๋ผ ํจ์ ๋ถ๋ชจ ์ปดํฌ๋ํธ๋ก๋ถํฐ ์ ๋ฌ ๋ฐ์ props ๊ฐ์ ๋ณํ๊ฐ ๋ฐ์ํ๊ฑฐ๋ ๋ถ๋ชจ ์ปดํฌ๋ํธ๊ฐ ๋ฆฌ ๋ ๋๋ง์ด ๋ฐ์์ ํ๋ ๊ฒฝ์ฐ ์ํ
- ํด๋น ์ปดํฌ๋ํธ ๋ด์์ state์ ๊ฐ์ด ๋ณํ๋ ๊ฒฝ์ฐ ์ํ
- forceUpdate() ๋ฉ์๋๋ฅผ ํตํด ๊ฐ์ ๋ก ๋ณ๊ฒฝํ๋ ๊ฒฝ์ฐ์ ํด๋น ๋ฉ์๋๊ฐ ์ํ
5. Unmounting - componentWillUnmount()
๐ก ์ปดํฌ๋ํธ ๋ด์์ DOM์ ์ ๊ฑฐํ ๋์ ์คํ์ด ๋๋ ๋ฉ์๋
- A, B๋ผ๋ ์ปดํฌ๋ํธ๊ฐ ์กด์ฌํ ๊ฒฝ์ฐ์ ํน์ ์ด๋ฒคํธ์ ๋ฐ๋ผ์ A๋ ๋ง์ดํธํ๊ณ , B๋ ์๋ง์ดํธ๋ฅผ ํ๊ณ ์ ํ ๋์ ์ด๋ฅผ ์ฌ์ฉ
- ์์
- A๋ผ๋ ์ปดํฌ๋ํธ ๋ด์์ B๋ผ๋ ์ปดํฌ๋ํธ๋ฅผ ๋ถ๋ฅด๊ณ ์์ ์ ์ ๋ผ๊ณ ํ ๋, B ์ปดํฌ๋ํธ๋ฅผ ์กฐ๊ฑด๋ถ์ ๋ฐ๋ผ์ ์๋ฉธ์ ์ํฌ ๊ฒฝ์ฐ ํด๋น ๋ผ์ดํ์ฌ์ดํด ๋ฉ์๋๊ฐ ์ํ.
functional component State & Lifecycle
๋ถ๋ฅ ํด๋์คํ ์ปดํฌ๋ํธ ํจ์ํ ์ปดํฌ๋ํธ
Mounting | constructor() | ํจ์ํ ์ปดํฌ๋ํธ ๋ด๋ถ |
Mounting | render() | return() |
Mounting | ComponenDidMount() | useEffect() |
Updating | componentDidUpdate() | useEffect() |
UnMounting | componentWillUnmount() | useEffect() |
๐ก [์๋ช ์ฃผ๊ธฐ ์์ ์์ฝ]
- ํจ์ํ ์ปดํฌ๋ํธ ํธ์ถ
- ํจ์ํ ์ปดํฌ๋ํธ ๋ด๋ถ ์คํ
- return()์ผ๋ก ํ๋ฉด ๋๋๋ง
- useEffect() ์คํ
[์กฐ๊ฑด๋ถ ์ํ] ๋ณ๊ฒฝ ํน์ ์ปดํฌ๋ํธ์ ์๋ฉธ์ด ๋ฐ์์ useEffect() ์คํ
1. Mounting - ์ปดํฌ๋ํธ ๋ด๋ถ
๐ก ์ปดํฌ๋ํธ๊ฐ ํธ์ถ ๋์์ ๋ ๊ฐ์ฅ ๋จผ์ ํธ์ถ ๋๋ ๊ฒ State๋ฅผ ์ ์ํ๊ฑฐ๋ ์ฌ์ฉ๋ ํจ์๋ค์ ๋ํด ๋ฏธ๋ฆฌ ์ ์
import { useState } from "react";
function LifecycleFunctionComponent(props){
**/**
* ์ปดํฌ๋ํธ ํธ์ถ ์ ๊ฐ์ฅ ๋จผ์ ํธ์ถ์ด ๋๋ ๊ณต๊ฐ
* ์ปดํฌ๋ํธ์์ ์ฌ์ฉ ๋ state๋ ํจ์๋ค์ ์ ์ ํ๋ ๊ณต๊ฐ์
๋๋ค.
*/**
console.log('ํด๋น ๋ถ๋ถ์ด ์ ์ผ ๋จผ์ ํธ์ถ')
const [userInfo,setUserInfo] = useState({
userId:'yuiseo',
userAge:28,
isShowTempComponent:false
})
return(
<>
</>
)
}
export default LifecycleFunctionComponent;
2. Mounting - return()
๐ก ๋ฏธ๋ฆฌ ๊ตฌํํ HTML๋ฅผ ํ๋ฉด์์ ๋ณด์ฌ์ฃผ๋ ๋ฉ์๋
- ํด๋น ๋ฉ์๋ ์์์๋ ๋ถ๋ชจ ์ปดํฌ๋ํธ์์ ์ ๋ฌ๋ฐ์ props ๊ฐ์ด ์ ๊ทผ ๊ฐ๋ฅ
- constructor()์์ ์ ์ํ state ๊ฐ์ ์ ๊ทผ์ด ๊ฐ๋ฅ
- ํด๋น ๊ณต๊ฐ์์ setState() ์ฌ์ฉ ๋ถ๊ฐ
import { useState } from "react";
function LifecycleFunctionComponent(props){
/**
* ์ปดํฌ๋ํธ ํธ์ถ ์ ๊ฐ์ฅ ๋จผ์ ํธ์ถ์ด ๋๋ ๊ณต๊ฐ
* ์ปดํฌ๋ํธ์์ ์ฌ์ฉ ๋ state๋ ํจ์๋ค์ ์ ์ ํ๋ ๊ณต๊ฐ์
๋๋ค.
*/
console.log('ํด๋น ๋ถ๋ถ์ด ์ ์ผ ๋จผ์ ํธ์ถ')
const [userInfo,setUserInfo] = useState({
userId:'yuiseo',
userAge:28,
isShowTempComponent:false
})
**/**
* ๋ฏธ๋ฆฌ ๊ตฌํํ HTML๋ฅผ ํ๋ฉด์์ ๋ณด์ฌ์ฃผ๋ ๋ฉ์๋์ด๋ค.
*/**
return(
<>
{console.log('rendering...')}
<div>
<div>Main Function Component</div>
<div>{userInfo.userAge}</div>
</div>
</>
)
}
export default LifecycleFunctionComponent;
3. Mounting/Updating/Unmounting - useEffect()
๐ก useEffect()๋ฅผ ํตํด Mounting/Updating/Unmounting ์ฒ๋ฆฌ๊ฐ ๊ฐ๋ฅ ํ๋์ ์ปดํฌ๋ํธ ๋ด์์ ์ฌ๋ฌ ๊ฐ ์ ์ธ์ด ๊ฐ๋ฅํ๋ฉฐ, ํ๋์ ๋ฉ์๋๋ก ์ฒ๋ฆฌ๋ฅผ ํด๋ ๋ฌด๋ฐฉ
๐ก [ ๋ฉ์๋ ๊ตฌ์กฐ ]
useEffect( function, deps? );
- function : useEffect๊ฐ ์ํ๋ ๋ ์คํ๋๋ ํจ์
- deps [optional] : ๋ฐฐ์ด ํํ์ด๋ฉฐ, ์์กด(dependency) ๊ฐ์ ์๋ฏธ </aside>
deps [optinal] ๊ฐ์ ์๋ฏธ
deps์ ๊ฐ ๊ตฌ์กฐ ์ค๋ช
๊ฐ์ด ์์ ๊ฒฝ์ฐ | useEffect(()⇒{}) | ํ๋ฉด์ด ๋ ๋๋ง ๋ ์ดํ ์ํ์ด ๋๋ฉฐ, ๋ฆฌ ๋ ๋๋ง์ด ๋ฐ์ํ๋ ๊ฒฝ์ฐ ๋ค์ ์ํ์ด ๋๋ค |
๋น ๋ฐฐ์ด ์ธ๊ฒฝ์ฐ | useEffect(()⇒{}, []) | ํ๋ฉด์ด ๋ ๋๋ง ๋ ์ดํ์๋ง ์ํ์ด ๋๋ค. |
๋ฐฐ์ด ๊ฐ์ด ์กด์ฌํ๋ ๊ฒฝ์ฐ | useEffect(()⇒{}, [๊ฐ]) | ํ๋ฉด์ด ๋ ๋๋ง ๋ ์ดํ์ ์ํ์ด ๋๊ณ , ‘๊ฐ’์ด ๋ณ๊ฒฝ๋์์ ๊ฒฝ์ฐ ํด๋น ๋ฉ์๋๊ฐ ์ํ์ด ๋๋ค. |
3.1 Mounting - useEffect()
๐ก ์ปดํฌ๋ํธ ๋ด์์ ๋ ๋๋ง์ด ์ํ๋ ์ดํ์ ์คํ์ด ๋๋ ๋ฉ์๋ deps ํ๋ผ๋ฏธํฐ๋ฅผ ๋น ๋ฐฐ์ด๋ก ์ํํ๋ฉด ๋ ๋๋ง์ด ์ํ๋ ์ดํ ์ต์ด ํ๋ฒ ์ํ
import { useState,useEffect } from "react";
function LifecycleFunctionComponent(props){
/**
* 1. ์ปดํฌ๋ํธ ํธ์ถ ์ ๊ฐ์ฅ ๋จผ์ ํธ์ถ์ด ๋๋ ๊ณต๊ฐ
* ์ปดํฌ๋ํธ์์ ์ฌ์ฉ ๋ state๋ ํจ์๋ค์ ์ ์ ํ๋ ๊ณต๊ฐ์
๋๋ค.
*/
console.log('ํด๋น ๋ถ๋ถ์ด ์ ์ผ ๋จผ์ ํธ์ถ')
const [userInfo,setUserInfo] = useState({
userId:'yuiseo',
userAge:28,
isShowTempComponent:false
})
**/**
* 3. ์ปดํฌ๋ํธ ๋ด์์ ๋ ๋๋ง์ด ์ํ๋ ์ดํ์ ์คํ์ด ๋๋ ๋ฉ์๋์ด๋ค.
*/
useEffect(()=>{
console.log('ํ๋ฉด์ด ๋๋๋ง ๋ ์ดํ์ ๋ฐ๋ก ์ํ : componentDidMoutn()์ ๋์ผ')
},[])**
/**
* 2. ๋ฏธ๋ฆฌ ๊ตฌํํ HTML๋ฅผ ํ๋ฉด์์ ๋ณด์ฌ์ฃผ๋ ๋ฉ์๋์ด๋ค.
*/
return(
<>
{console.log('rendering...')}
<div>
<div>Main Function Component</div>
<div>{userInfo.userAge}</div>
</div>
</>
)
}
export default LifecycleFunctionComponent;
3.2 Updating - useEffect()
๐ก ์ปดํฌ๋ํธ ๋ด์์ ๋ณํ๊ฐ ๋ฐ์ํ์์ ๊ฒฝ์ฐ์ ์คํ๋๋ ๋ฉ์๋
- ๋ณํ
- ๋ถ๋ชจ ์ปดํฌ๋ํธ๋ก๋ถํฐ ์ ๋ฌ๋ฐ์ props๊ฐ์ ๋ณํ๊ฐ ๋ฐ์
- ๋ถ๋ชจ ์ปดํฌ๋ํธ๊ฐ ๋ฆฌ๋ ๋๋ง์ด ๋ฐ์ํ๋ ๊ฒฝ์ฐ
- ํด๋น ์ปดํฌ๋ํธ ๋ด์์ state์ ๊ฐ์ด ๋ณํ๋ ๊ฒฝ์ฐ ์ํ
import { useState,useEffect } from "react";
function LifecycleFunctionComponent(props){
/**
* 1. ์ปดํฌ๋ํธ ํธ์ถ ์ ๊ฐ์ฅ ๋จผ์ ํธ์ถ์ด ๋๋ ๊ณต๊ฐ
* ์ปดํฌ๋ํธ์์ ์ฌ์ฉ ๋ state๋ ํจ์๋ค์ ์ ์ ํ๋ ๊ณต๊ฐ์
๋๋ค.
*/
console.log('ํด๋น ๋ถ๋ถ์ด ์ ์ผ ๋จผ์ ํธ์ถ')
const [userInfo,setUserInfo] = useState({
userId:'yuiseo',
userAge:28,
isShowTempComponent:false
})
**/**
* 3. ์ปดํฌ๋ํธ ๋ด์์ ๋ ๋๋ง์ด ์ํ๋ ์ดํ์ ์คํ์ด ๋๋ ๋ฉ์๋์ด๋ค.
*/
useEffect(()=>{
console.log('์ ๋ฌ ๋ฐ์ props์ ๊ฐ์ ๋ณํ๊ฐ ์๊ฒผ์ ๊ฒฝ์ฐ / ์ฌ์ฉ์ ๋์ด์ ๋ณํ๊ฐ ๋ฐ์ํ์์ ๊ฒฝ์ฐ')
},[props.appState,userInfo.userAge])**
/**
* 2. ๋ฏธ๋ฆฌ ๊ตฌํํ HTML๋ฅผ ํ๋ฉด์์ ๋ณด์ฌ์ฃผ๋ ๋ฉ์๋์ด๋ค.
*/
return(
<>
{console.log('rendering...')}
<div>
<div>Main Function Component</div>
<div>{userInfo.userAge}</div>
</div>
</>
)
}
3.3 Unmonting - useEffect()
๐ก ์ปดํฌ๋ํธ ๋ด์์ DOM์ ์ ๊ฑฐํ ๋์ ์คํ๋๋ ๋ฉ์๋
- ์ปดํฌ๋ํธ์ DOM์ด ์ ๊ฑฐ๋ ๋์ ์ํ
- ์์
- A๋ผ๋ ์ปดํฌ๋ํธ ๋ด์์ B๋ผ๋ ์ปดํฌ๋ํธ๋ฅผ ๋ถ๋ฅด๊ณ ์์ ์ ์ ๋ผ๊ณ ํ ๋, B ์ปดํฌ๋ํธ๋ฅผ ์กฐ๊ฑด๋ถ์ ๋ฐ๋ผ์ ์๋ฉธ์ ์ํฌ ๊ฒฝ์ฐ ํด๋น ๋ผ์ดํ์ฌ์ดํด ๋ฉ์๋๊ฐ ์ํ
import { useState,useEffect } from "react";
function LifecycleFunctionComponent(props){
/**
* 1. ์ปดํฌ๋ํธ ํธ์ถ ์ ๊ฐ์ฅ ๋จผ์ ํธ์ถ์ด ๋๋ ๊ณต๊ฐ
* ์ปดํฌ๋ํธ์์ ์ฌ์ฉ ๋ state๋ ํจ์๋ค์ ์ ์ ํ๋ ๊ณต๊ฐ์
๋๋ค.
*/
console.log('ํด๋น ๋ถ๋ถ์ด ์ ์ผ ๋จผ์ ํธ์ถ')
//unMount
const [isShowTempComp,setIsShowTempComp]=useState(true)
const [userInfo,setUserInfo] = useState({
userId:'yuiseo',
userAge:28,
isShowTempComponent:false
})
/**
* 3. ์ปดํฌ๋ํธ ๋ด์์ ๋ ๋๋ง์ด ์ํ๋ ์ดํ์ ์คํ์ด ๋๋ ๋ฉ์๋์ด๋ค.
*/
// useEffect(()=>{
// console.log('์ ๋ฌ ๋ฐ์ props์ ๊ฐ์ ๋ณํ๊ฐ ์๊ฒผ์ ๊ฒฝ์ฐ / ์ฌ์ฉ์ ๋์ด์ ๋ณํ๊ฐ ๋ฐ์ํ์์ ๊ฒฝ์ฐ')
// },[props.appState,userInfo.userAge])
/**
* ์์ ์ปดํฌ๋ํธ Unmount
*/
const fn_unmountCompoent = () => {
setIsShowTempComp(!isShowTempComp);
}
/**
* 2. ๋ฏธ๋ฆฌ ๊ตฌํํ HTML๋ฅผ ํ๋ฉด์์ ๋ณด์ฌ์ฃผ๋ ๋ฉ์๋์ด๋ค.
*/
return(
<>
{console.log('rendering...')}
<div>
<div>Main Function Component</div>
<button onClick={fn_unmountCompoent}>delete Component</button>
{
isShowTempComp && (
<LifecycleUnmountComponent/>
)
}
</div>
</>
)
}
function LifecycleUnmountComponent(){
useEffect(()=>{
return(
console.log('LifecycleUnmountComponent๊ฐ Unmount ๋์์')
)
},[])
return(
<div>
<h1>Unmount Component</h1>
</div>
)
}
//MAIN FUNCTION
function App() {
return (
<div className="App">
<h1> hola, yo soy iseo</h1>
<LifecycleFunctionComponent/>
</div>
);
}
export default App;
import { useState,useEffect } from "react";
function LifecycleFunctionComponent(props){
/**
* 1. ์ปดํฌ๋ํธ ํธ์ถ ์ ๊ฐ์ฅ ๋จผ์ ํธ์ถ์ด ๋๋ ๊ณต๊ฐ
* ์ปดํฌ๋ํธ์์ ์ฌ์ฉ ๋ state๋ ํจ์๋ค์ ์ ์ ํ๋ ๊ณต๊ฐ์
๋๋ค.
*/
console.log('ํด๋น ๋ถ๋ถ์ด ์ ์ผ ๋จผ์ ํธ์ถ')
//unMount
const [isShowTempComp,setIsShowTempComp]=useState(true)
const [userInfo,setUserInfo] = useState({
userId:'yuiseo',
userAge:28,
isShowTempComponent:false
})
/**
* 3. ์ปดํฌ๋ํธ ๋ด์์ ๋ ๋๋ง์ด ์ํ๋ ์ดํ์ ์คํ์ด ๋๋ ๋ฉ์๋์ด๋ค.
*/
// useEffect(()=>{
// console.log('์ ๋ฌ ๋ฐ์ props์ ๊ฐ์ ๋ณํ๊ฐ ์๊ฒผ์ ๊ฒฝ์ฐ / ์ฌ์ฉ์ ๋์ด์ ๋ณํ๊ฐ ๋ฐ์ํ์์ ๊ฒฝ์ฐ')
// },[props.appState,userInfo.userAge])
/**
* ์์ ์ปดํฌ๋ํธ Unmount
*/
const fn_unmountCompoent = () => {
setIsShowTempComp(!isShowTempComp);
}
/**
* 2. ๋ฏธ๋ฆฌ ๊ตฌํํ HTML๋ฅผ ํ๋ฉด์์ ๋ณด์ฌ์ฃผ๋ ๋ฉ์๋์ด๋ค.
*/
return(
<>
{console.log('rendering...')}
<div>
<div>Main Function Component</div>
<button onClick={fn_unmountCompoent}>delete Component</button>
{
isShowTempComp && (
<LifecycleUnmountComponent/>
)
}
</div>
</>
)
}
function LifecycleUnmountComponent(){
useEffect(()=>{
return(
console.log('LifecycleUnmountComponent๊ฐ Unmount ๋์์')
)
},[])
return(
<div>
<h1>Unmount Component</h1>
</div>
)
}
//MAIN FUNCTION
function App() {
return (
<div className="App">
<h1> hola, yo soy iseo</h1>
<LifecycleFunctionComponent/>
</div>
);
}
export default App;
'Development > React.js' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[React] port ๋ฒํธ ๋ณ๊ฒฝํ๊ธฐ (0) | 2023.01.23 |
---|---|
[React] React Hook API (0) | 2023.01.18 |
SPA / CSR / TTI / TTV / SEO / Metaํ๊ทธ / Opengraph (0) | 2022.10.14 |
์ํฐ๋ ํ๋ฆฌ์จ๋ณด๋ฉ ์ฑ๋ฆฐ์ง ์ฌ์ ๊ณผ์ (CSR / SSR with Next.js) (0) | 2022.09.28 |
[React]Modal ํ์ ์ ๋ท๋ฐฐ๊ฒฝ ์คํฌ๋กค ๋์ง ์๊ฒ ํ๊ธฐ (0) | 2022.08.13 |
๋๊ธ