전체 글95 Zustand vs Context API 항목ZustandContext API종류외부 상태 관리 라이브러리React 내장 기능목적전역 상태 간단하고 효율적으로 관리전역 상태 전달 목적 (주입)상태 업데이트구독 기반 (Selective rendering)모든 하위 컴포넌트가 리렌더링복잡도간단한 문법, 빠른 설정Provider/Consumer 구조 필요의존성있음 (zustand 설치 필요)없음 (React 내장) 구독 기반? 📌 Context API// CounterContext.tsxconst CounterContext = createContext(null)const CounterProvider = ({ children }) => { const [count, setCount] = useState(0) const increase = () =>.. 2025. 6. 30. d 2024. 3. 19. React.StrictMode https://devshoveling.tistory.com/entry/ReactReactStrictMode%EC%97%90-%EB%8C%80%ED%95%B4%EC%84%9C 2024. 3. 7. [React] input 태그에 숫자만 입력되게 / input number 버튼 없애기 1 input 태그에 숫자만 입력되게 { if (birth.length > 8 && e.key !== "Backspace") { e.preventDefault(); } }} onChange={(e: React.ChangeEvent) => { const { value } = e.target; const onlyNum = value.replace(/[^0-9]/g, ""); setBirth(onlyNum); }} /> input창에 숫자만 입력되게 하려면, 정규식을 이용하여 숫자가 아닌 것들은 ''으로 바꾸어버리면 된다. 그런데 당황스럽게도 이 방법을 사용하니 maxLenght가 적용이 안되는 것이다 💦 그래서 onKeyDown을 이용하여 value가 8자리 이상일 땐 '뒤로가기' 외의 키는 안먹히도록 따로.. 2024. 1. 17. 이전 1 2 3 4 ··· 24 다음