这是我的render()
方法
render() {
let { enableGo } = this.props;
console.log("value enable go", enableGo);
let { activeTab } = this.state;
let toastText;
let showToast;
switch (enableGo) {
case true:
showToast = true;
toastText = "Signup Completed!";
break;
case false:
toastText = "Signing up...Please wait";
showToast = true;
break;
}
....
我正要显示和隐藏<View/>
基于enableGo的道具
{showToast && (
<View
style={{
borderRadius: scale(20),
width: scale(150),
alignItems: "center",
justifyContent: "center",
height: verticalScale(25),
flexDirection: "row",
}}
>
<Text style={{ color: 'red', fontSize: 12 }}>
{toastText}
</Text>
{!toastText === "Signup Completed" && (
<Spinner color='red' size="small" />
)}
</View>
)}
....
我最终<View/>
在文本更改后没有隐藏,并且showToast
变成undefined
.
如何使文本先更改,然后延迟隐藏视图?