如何根据另一个屏幕上的更改重新呈现屏幕内容

时间:2020-10-26 09:09:23

标签: reactjs react-native react-navigation

因此,我对本机做出反应还很陌生,并且陷入了困境。 我有两个屏幕,一个是UserProfile,另一个是EditProfile,我们可以通过使用反应导航按一个按钮从UserProfile导航到EditProfile。

因此,UserProfile有一个用户图片,在EditProfile中我们可以编辑(上传/删除)该图片,我已经实现了在EditProfile屏幕中编辑图片的逻辑。

现在,我希望每当在EditProfile屏幕中编辑个人资料图片时,所做的更改也应反映在UserProfile屏幕中,即,包含图片的组件应重新呈现,我应该如何实现?

1 个答案:

答案 0 :(得分:0)

您可以使用:

  1. 上下文。 https://reactjs.org/docs/context.html#when-to-use-context
  2. Redux。 https://redux.js.org/basics/example
  3. 您可以使用EditProfile的回调来更新Parent组件,并且UserProfile将使用新的道具进行更新。 https://reactjs.org/docs/components-and-props.html