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