2017-08-09 205 views
0

在React Native中更改頭像時,我遇到了問題。 我使用react-native-router和Actions來移動屏幕。 當我在個人資料屏幕上更改頭像時。這是成功。但是當我回到主頁時。它不會更改頭像,因爲它不刷新。它使用舊數據。 請給我一個解決方案,幫助我。謝謝。如何在React Native中更改和設置新的頭像?

這裏是分佈屏幕

enter image description here

下面是主頁

enter image description here

+0

這將是更有幫助,如果你可以張貼一些代碼。 –

回答

0

當你調用Actions.pop({刷新:{重裝: '重裝'}})componentWillReceiveProps是在之前的場景中調用,您可以更新當前組件。

0

你必須調用方法componentWillReceiveProps在網頁上,類似

componentWillReceiveProps(nextProps) { 
    if (nextProps.avatar.object) { 
    * here update field responsible for rendering avatar img in component* 
    } 
} 
相關問題