I want to directly update the value of a component due to performance reasons.
render(){ <View> <Text style={styles.welcome} ref={component => this._text = component}> Some Text </Text> <TouchableHighlight underlayColor='#88D4F5' style={styles.button}> <View> <Text style={styles.buttonText} onPress={this.useNativePropsToUpdate.bind(this)}> Iam the Child </Text> </View> </TouchableHighlight> </View> }
This is the method that I use to update the text component. I do not know if I am setting the correct attribute / how to determine which attribute to set:
useNativePropsToUpdate(){ this._text.setNativeProps({text: 'Updated using native props'}); }
Essentially, trying to follow the same approach from this example: https://rnplay.org/plays/pOI9bA
Edit: When I try to explicitly assign an updated value:
this._text.props.children = "updated";
(I know this is the right way to do things in RN). I get the error "Unable to assign read-only property to children of object" # ""
So maybe thatβs why for some reason it canβt be updated in RN for some reason?
source share