목록input (3)
COCO World
trim() 자체적으로 양 옆 공백을 제거해주는 메서드 replace() 정규식을 이용하여 양 옆 공백을 제거해주는 메서드로 좀 더 커스터마이징으로 활용 가능 1. trim() let str = ' 반가워요! '; let trimValue = str.trim(); console.log(trimValue); // 출력 '반가워요!' 2. replace() let str = ' 반가워요! '; let trimValue = str.replace(/^\s+|\s+$/gm, ''); console.log(trimValue); // 출력 '반가워요!' 2-1. replace의 모든 공백 제거 let str = ' 반 가 워 요 ! '; let trimValue = str.replace(/ /gi, ''); cons..

코드 구조 const Page = () => { const onChanged = useCallback((e) => { e.target.value = e.target.value.trim() const value = e.target.value; onChange(e); },[onChange]); return ( ) } onChange의 역할 : 입력 상태가 실시간으로 업데이트되어 최신 상태를 유지하며, 사용자에게 실시간 피드백을 제공 단점: 상태 업데이트가 발생할 때마다 컴포넌트가 재렌더링되어 성능에 영향을 줄 수 있다. 따라서, onChange 메서드 값의 변경이 있을 때에만 onChanged의 함수가 실행될 수 있도록 useCallback을 통해 onChange를 의존성 배열에 넣어두었고, input의 입..

1. 사건 해결장면 2. 코드 현황 state들 // 유저리스트 데이터 state const [userList, setUserList] = useState([] as any); // 검색 조건 state const [searchTerm, setSearchTerm] = useState(''); const [filterList, setFilterList] = useState([] as any); 체크 박스 관련 변수들 // 개별 항목을 체크했을 때의 state const [isCheckingBox, setIsCheckingBox] = useState(false); // 체크항목 저장하는 변수 state const [checkedArr, setCheckedArr] = useState([]); // 개별 체크표..