【发布时间】:2021-08-06 06:02:54
【问题描述】:
我想通过一些代码更改在渲染屏幕之前执行 display: "none"。
现在{goodbotton} 会在屏幕渲染时临时出现。
目前我的代码如下。
...
const [ goodbotton, setGoodBotton ] = useState(<Image source={require('../../images/good_botton_inactive.png')} style={ {width: 65, height: 65} }/>);
<TouchableOpacity
onPress={() => {
if (image.is_my_good) {
postGood(image.id, false)
} else {
setGoodBotton(<Image source={require('../../images/good_botton.png')} style={ {width: 65, height: 65}}/>)
postGood(image.id, true)
setTimeout(() => {
setGoodBotton(<Image source={require('../../images/good_botton_inactive.png')} style={ {width: 65, height: 65}}/>)
}, 500)
}
}}>
<View style={[image?.is_my_good ? styles.hide_good_botton : {}, commonStyles.shadow]} >
{goodbotton}
</View>
</TouchableOpacity>
const styles = StyleSheet.create({
hide_good_botton: {
display: "none"
}
});
你有什么想法吗?
【问题讨论】: