티스토리 뷰

얘도 적어두면 언젠간 쓰겠지...?

function WriteEditor({title, body, onChangeTitle, onChangeBody}) {
  const bodyRef = useRef();
  return (
    <View style={styles.block}>
      <TextInput
        placeholder="제목을 입력하세요"
        style={styles.titleInput}
        returnKeyType="next"
        onChangeText={onChangeTitle}
        value={title}
        onSubmitEditing={() => {
          bodyRef.current.focus();
        }}
      />
      <TextInput
        placeholder="당신의 오늘을 기록해보세요"
        style={styles.bodyInput}
        multiline
        textAlignVertical="top"
        onChangeText={onChangeBody}
        value={body}
        ref={bodyRef}
      />
    </View>
  );
}

 

- useRef().focus() = 포커스

- useRef().blur() = 포커스 해제

- useRef().clear() = 내용을 모두 비움

 

'Mobile > react-native' 카테고리의 다른 글

[react-native] date-fns  (0) 2024.01.26
[react-native] uuid  (0) 2024.01.23
[react-native] FloatingButton Template  (1) 2024.01.23
[react-native] Context API  (0) 2024.01.22
[react-native] useFocusEffect  (0) 2024.01.16
Comments