1
I have my own page:
import React from 'react';
import {
ScrollView,
StyleSheet,
Text,
Button,
} from 'react-native';
export default class ArticlesScreen extends React.Component {
constructor(props) {
super(props);
this.state = {
teste: 'Teste'
};
}
funcao () {
this.state.teste = 'blabla';
}
render() {
return (
<ScrollView style={styles.container}>
<Text>
{ this.state.teste }
</Text>
<Button
onPress={ () => this.funcao()}
title="Press Me"
color="#841584"
/>
</ScrollView>
);
}
}
This function will show on the screen the word Teste followed by a purple button. When I click the button the value of the test variable is changed to 'Blabla' and I know this because I had it printed on the console.
But on the screen is not updating, The name Teste is still appearing on the screen and is not being uploaded by blabla. How do I update this field in specific, without having to reload the entire page?
I did it without the bind, and it didn’t go wrong. But I understood the bind function.
– Vinicius Morais