【发布时间】:2021-12-12 12:51:39
【问题描述】:
我是本机反应的新手,试图在相同的按钮按下事件上重定向和添加数据。我尝试在等待操作后使用 .then ,但无法正常工作 要么是添加数据,要么是重定向——不知道如何将两者结合起来?
<Button title="Add now !"
onPress={ ()=> addtoStorage(initname, initclas, initsubject) }
addtoStorage = async(par1, par2, par3) =>{
try{
let makeObject = {name:par1, class:par2, subject:par3,
id: Increase.key.toString()};
console.log(makeObject);
await AsyncStorage
.setItem( makeObject.id , JSON.stringify(makeObject) )
.then(Increase())
.then(moveAround.navigate(first)); //not working here
} catch(e){
}
console.log('done');
}
【问题讨论】:
标签: react-native button react-navigation hybrid-mobile-app asyncstorage