reactjs - React 中的嵌套子组件 + 渲染新数据
问题描述
需要帮助,我目前正在学习反应,在创建博客应用程序时遇到了某种问题。
我将组件相互嵌套,但是除非我刷新嵌套组件的页面,否则子组件中不会收到更新的数据。下面是我的代码片段在 AccountOverview 组件中是另一个处理表单的组件(容器)。一旦表单提交数据并且后端处理数据,我希望 AccountOverview 组件将呈现新信息。但是,如果我随后返回父级(仪表板)并进行编辑,则 AccountOverview 组件不会显示新创建的数据,除非是在整页刷新时。
class Dashboard extends Component {
state = {}
componentDidMount(){
this.props.getCurrentProfile();
}
render() {
const { user } = this.props.auth;
const { profile, loading } = this.props.profile;
return (
<div style={{margin: "0", padding: "0"}}>
<Header title="Account Dashboard" />
<section id="accountPage" className="">
<div className="container">
<div className="row">
<Sidebar />
<main className="col-sm-9 col-md-9 account">
<div className="dashboard">
<AccountOverviewPanel
user={user} profile={profile} loading={loading}
/>
<PostTablePanel />
</div>
</main>
</div>
</div>
</section>
</div>
);
};
};
解决方案
您的提交操作是否会导致您的组件卸载。我尝试克隆您的代码。它似乎错过了密钥文件,因此无法运行它
推荐阅读
- typo3-11.x - 在typo3扩展版本11.2中动态生成javascript
- node.js - 关于Spring Boot的加密方式的一个问题
- sql - 如何从 IEnumerable 获取数据
? - python - ASCII 编解码器不能编码字符,只能 concat str
- python - 如何在python中将列表列表与引用变量连接起来
- react-native - ref.current null 不是对象
- javascript - 如何禁用pdf查看器的屏幕截图
- c++ - 插入空向量后大小为零的向量
- javascript - 在从注册表单中检索名称之前触发 Firebase onAuthStateChanged()?
- javascript - 我该如何做第一个图像上传输入选项将启用上传其余图像上传输入选项将被 Jquery 禁用?