[ JS Library/React ]
useMemo 를 사용하여 연산한 값 재사용하기
2022-05-24 17:29:59
성능 최적화를 위하여 연산된 값을 useMemo 라는 Hook 을 사용하여 재사용 하는 방법을 알아보자 App 컴포넌트에서 아래와 같이 countActiveUsers 라는 함수를 만들어서, active 값이 true 인 사용자의 수를 세어서 화면에 렌더링 해보자 App.js import React, {useRef, useState} from 'react'; import CreateUser from './components/CreateUser'; import UserList from "./components/UserList"; function App() { function countActiveUsers(users) { console.log("active 값이 ture 인 유저의 수를 센는중..."); re..