动态更改抽屉左右按钮图像?
问题描述:
反应本地路由器通量v3.37.0 反应母语v0.42.0动态更改抽屉左右按钮图像?
我试图动态更新抽屉导航栏右侧图像,我已经使用leftButtonImage,rightButtonImage,其中一次用户阅读我想要更改按钮图像的所有通知。
我无法设法重新呈现或更新此按钮图像,此功能不被支持或有什么,我失踪?
答
您可以拨打Actions.refresh
当你需要刷新视图,例如:
Actions.refresh({key: 'profileView', renderRightButton: this.renderRightButton });
,也定义renderRightButton:
renderRightButton() {
return (
<TouchableOpacity onPress={ console.log(this) } >
<Text>Logout</Text>
</TouchableOpacity>
)
}
,最后不要忘了从导入反应原生操作 - 路径通量
import {Actions} from 'react-native-router-flux';
+0
这将无法正常工作,它会覆盖行动和事情去与行动失踪 –
答
您可以使用重新呈现或states
。
检查你想要的,并应用以下各州图像资源。(或道具)
let NotiImage = {
normal: require('../assets/image/notinormal.png');
new: require('../assets/image/new.png');
}
render() {
...
<Image source={ this.state.newNoti ? NotiImage.new : NotiImage.normal } />
...
}
如果道具或组件状态的变化,它应该更新的状态。您应该放置相关代码片段,以便我们看看是否有任何问题。 –