javascript - 修复了更改用户的个人资料页面时不会重新渲染的组件
问题描述
const Profile = () => {
return(
<div>
<ProfileData/>
<Switch>
<Route exact path="/profile/:user" component={(props) => (<ProfileScreen {...props}/>)}/>
<Route exact path="/profile/:user/followers" component={(props) => (<ProfileFollowers {...props}/>)}/>
<Route exact path="/profile/:user/following" component={(props) => (<ProfileFollowing {...props}/>)}/>
<Route component={NotFound}/>
</Switch>
</div>
)
}
因此,在上述路线中,我有一个组件 ProfileData,其中包含有关用户的名称和其他一般信息。在浏览用户的关注者和关注者时,此组件不会重新呈现,但现在当我在关注者部分(使用 NavLink)单击用户时,上述 ProfileData 不会重新呈现并包含有关前一个用户的信息。解决此问题的最佳方法是什么,以便在导航到另一个用户的个人资料页面时重新呈现 ProfileData?
解决方案
推荐阅读
- python - 4维数据经过卷积神经网络后变成2维
- reactjs - 调用 this.props.dispatch 两次
- regex - 使用 sed 从 XML 节点中删除内容
- ios - 如何为项目内不同组的多个图像设置动画?
- python - Python数据帧对大量数据的笛卡尔运算
- sql - SQL合并不插入新行
- python - 使用 Keras 进行序列到序列学习
- javascript - 悬停时的图像出现更多图像(画廊排序) Html css Javascript
- python - 打印 df.head() 时 JupyterLab 崩溃
- oracle - PLS 00357 错误 - 上下文中不允许使用表、视图或序列“txt.col1”