I have 2 screens:
My entry point is my Home screen, if I am connected (obtaining data), log out and then log in to another account. Since my startup component is already mounted, my data will not be updated. I can not find solutions, I think I need to use "ComponentWillUpdate" in my Home.js or something, but you can not find the solution.
Here is my code:
Start.js
componentDidMount = async () => {
const {navigation} = this.props;
if (! wait AsyncStorage.getItem (& # 39; auth & # 39;)) {
navigation.navigate (& # 39; Login & # 39;);
} else {
this.getDatas ();
}
}
getDatas () {
axios.get (`$ {apiUrl} / me`) .then ((res) => {
this.setState ({
datas: res.data.datas,
});
}). catch ((err) => {
console.warn (err);
});
}
Login.js
export the default class Log on extends the component {
builder (accessories) {
super (accessories);
this.state = {
email: null,
password: null,
};
}
log in() {
const {email, password} = this.state;
axios.post (`$ {apiUrl} / auth`, {
email,
password
}). then ((res) => {
navigation.navigate (& # 39; Start & # 39;);
}). catch ((err) => {
console.warn (& # 39; Error: & # 39 ;, err);
});
}
}
Any ideas ?