2017-07-04 27 views
0

反應本地路由器通量v3.37.0 反應母語v0.42.0動態更改抽屜左右按鈕圖像?

enter image description here

我試圖動態更新抽屜導航欄右側圖像,我已經使用leftButtonImage,rightButtonImage,其中一次用戶閱讀我想要更改按鈕圖像的所有通知。

我無法設法重新呈現或更新此按鈕圖像,此功能不被支持或有什麼,我失蹤?

+0

如果道具或組件狀態的變化,它應該更新的狀態。您應該放置相關代碼片段,以便我們看看是否有任何問題。 –

回答

0

您可以撥打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

這將無法正常工作,它會覆蓋行動和事情去與行動失蹤 –

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 } /> 

    ... 
}