just wanted to ask about the possible ways to navigate to a screen upon a successful api response in react native.. I have been using redux for state management in projects.
I have tried a few ways and would like suggestions of good practice from you all.
let promise = new Promise(function(resolve, reject) {
setTimeout(() => resolve("done!"), 1000);
//api call here
});
promise.then(
result => alert(result), //navigation login
error => alert(error) // error handling
);
use useNavigation hooks to navigate to a particular screen.
const navigation = useNavigation();
let promise = new Promise(function(resolve, reject) {
setTimeout(() => resolve("done!"), 1000);
//api call here
});
promise.then(
result => navigation.navigate('OtherScree',{
result:result}), //navigation login
error => alert(error) // error handling
);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.