목록2026/03/15 (1)
co-cherry
커스텀 훅을 활용한 로직 분리 커스텀 훅(Custom Hook)반복되는 로직을 React의 내장 훅을 활용하여 재사용 가능한 형태로 분리한 사용자 정의 훅 예를 들어, 같은 input 로직이 두 컴포넌트에 있다고 가정해보자. EmailInput (Before)import { useState } from "react";function EmailInput() { const [email, setEmail] = useState(""); const handleChange = (e: React.ChangeEvent) => { setEmail(e.target.value); }; return ( );}export default EmailInput; NicknameInput (Before)import {..
React
2026. 3. 15. 19:38
