LifeCycle
react hooks
useState
- State를 만들 때는 useState()를 사용
const [ value, setValue ] = useState( 초기값 )
useEffect
- 리액트 컴포넌트가 렌더링될 때마다 특정 작업을 수행하도록 설정할 수 있는 Hook
// src/App.js
import React, { useEffect } from "react";
const App = () => {
useEffect(() => {
// 이 부분이 실행된다.
console.log("hello useEffect");
});
return <div>Home</div>;
}
export default App;
'⛵ 항해99 > TIL · WIL ✏️' 카테고리의 다른 글
[TIL] 2023.09.13 - axios(비동기 통신) (0) | 2023.09.14 |
---|---|
[TIL] 2023.09.12 - jsonserver (0) | 2023.09.12 |
[TIL] 2023.09.09 - Redux Toolkit (0) | 2023.09.09 |
[TIL] 2023.09.08 - Event.stopPropagation() (0) | 2023.09.08 |
[TIL] 2023.09.07 - overflow: hidden 부분 적용 방법(position: fixed) (0) | 2023.09.07 |