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 | 31 |
Tags
- variable object
- lexical environment
- BIND
- activation object
- 객체
- happy hacking
- 화살표 함수
- Execution Context
- type
- react router
- react-router
- function 표현식
- webstorm
- Arrow function
- scope chain
- vs code
- function 문
- hoisting
- 정적스코프
- 리액트 라우터
- lexical scope
- 함수 표현식
- This
- 실행컨텍스트
- moment.js
- 함수
- JavaScript
- 호이스팅
- function
- 자바스크립트
Archives
- Today
- Total
목록2021/05 (1)
Pandaman Blog
[React.js] React Hook 에서 이전 props 또는 state를 얻는 방법
클래스형 컴포넌트를 함수형 컴포넌트로 변경하는 작업을 진행하면서 이전 상태를 알아야 하는 경우가 발생했다. react 공식 문서에서 확인해보면 아래와 같은 예제를 통해 알려주고 있다. function Counter() { const [count, setCount] = useState(0); const prevCountRef = useRef(); useEffect(() => { prevCountRef.current = count; }); const prevCount = prevCountRef.current; return Now: {count}, before: {prevCount}; } 해당 코드를 다시 Custom Hook으로 변경 가능하다. function Counter() { const [count, ..
Front end/React
2021. 5. 30. 21:17