Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { createRef } from 'react'
- import { View, TextInput } from 'react-native'
- const textInputRef = createRef() // ref object. Has an instance so that it can save the ref info of your node, yeah
- const onChangeText = text => { // floating function
- if (textInputRef.current) {
- textInputRef.current.setNativeProps({ text })
- }
- }
- const SampleSFC = () => (
- <View>
- <TextInput
- ref={textInputRef}
- onChangeText={onChangeText}
- />
- </View>
- )
Add Comment
Please, Sign In to add comment