I have my following 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 display the word Teste
on the screen 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 to print on the console.
But the screen is not updating, the name Teste
is still appearing on the screen and is not being replaced with blabla
. How do I update this field in specific, without having to reload the entire page?