Anda di halaman 1dari 6

Input

TextInput
• Komponen untuk input text
• Library ‘react-native’

import React, {Component} from 'react';


import {TextInput} from 'react-native';

export default class ContohText extends Component{


render(){
return(
<TextInput placeholder=“Enter your text here” />
)
}
}
Props TextInput
• onChangeText → event output perubahan nilai text
• returnKeyType → type gesture ketika enter dari keyboard
• keyboardType → type keyboard
• onSubmitEditing → event ketika submit dari input text
• placeholderTextColor →warna text placeholder
• style → memberikan stylesheet
Focus TextInput
• Fungsi focus di TextInput dengan ref
• <ref>.focus()

import React, {Component} from 'react';


import {TextInput} from 'react-native';

export default class ContohText extends Component{


componentDidMount(){
setTimeout(()=> this.inputRef.focus(), 10)
}
render(){
return(
<TextInput ref={(input)=> this.inputRef = input} />
)
}
}
Picker
• Komponen native untuk memilih nilai
Question & Answers

Anda mungkin juga menyukai