Guest User

Untitled

a guest
Jul 20th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. import React, { createRef } from 'react'
  2. import { View, TextInput } from 'react-native'
  3.  
  4. const textInputRef = createRef() // ref object. Has an instance so that it can save the ref info of your node, yeah
  5.  
  6. const onChangeText = text => { // floating function
  7. if (textInputRef.current) {
  8. textInputRef.current.setNativeProps({ text })
  9. }
  10. }
  11.  
  12. const SampleSFC = () => (
  13. <View>
  14. <TextInput
  15. ref={textInputRef}
  16. onChangeText={onChangeText}
  17. />
  18. </View>
  19. )
Add Comment
Please, Sign In to add comment