如何在React Native中更改和设置新的头像?

时间:2017-08-09 09:07:11

标签: react-native

我在React Native中更改头像时遇到问题。 我使用react-native-router和Actions来移动屏幕。 当我在个人资料屏幕上更改头像时。它的成功。但是当我回到主页时。它不会改变头像,因为它不会刷新。它使用旧数据。 请帮我解决一下。谢谢。

这是个人资料屏幕

enter image description here

这是主页

enter image description here

2 个答案:

答案 0 :(得分:0)

当你调用Actions.pop({refresh:{reload:' reload'}}时)在前一个场景中调用componentWillReceiveProps,你可以更新当前组件。

答案 1 :(得分:0)

您必须在主页中调用方法componentWillReceiveProps,例如

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