리액트, 커서 위치 맨 마지막으로 설정하기
useEffect(() => {
// focus when it is edit mode
if (isEditing) {
const messageLength = messageRef.current.value.length;
messageRef.current.focus();
//place the location of the cursor to the last
messageRef.current.setSelectionRange(messageLength, messageLength);
}
}, [isEditing]);
728x90
반응형
'부트캠프 개발일지 2023-2024 > Bootcamp 생활기록' 카테고리의 다른 글
[8주차] 리액트: Firestore의 Cloud Storage 사용하기 (0) | 2023.11.22 |
---|---|
[8주차] 리액트: 그룹 프로젝트 newsfeed, 음악 커뮤니티 만들기 (0) | 2023.11.21 |
[7주차] 스탠다드 특강 : 리액트 라이프사이클, axios, loading/error (0) | 2023.11.17 |
[7주차] 리액트: json 데이터를 서로다른 페이지에서 모두 받아야하는 경우 (0) | 2023.11.16 |
[7주차] 리액트: 확인/취소 알림창 (0) | 2023.11.16 |