[React Native] TextInput

설정·2021년 12월 26일
0

ReactNative

목록 보기
11/30

# TextInput Code Example

const [text, setText] = React.useState("");

const onChangeText = (event) => setText(event); // event는 value 값
const addTodo = () => {
	alert(text)
}

return (
<View>
	<TextInput
		onSubmitEditing={addTodo}
		onChangeText={onChangeText}
		value={text}
		returnKeyType="previous"
	/>
</View>
);

1. returnKeyType

▶ Refer to https://reactnative.dev/docs/textinput#returnkeytype

2. onChangeText

▶ Refer to https://reactnative.dev/docs/textinput#onchangetext

  • onChangeText(callback)

3. onSubmitEditing

▶ Refer to https://reactnative.dev/docs/textinput#onsubmitediting

  • onSubmitEditing(callback)

0개의 댓글