Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 修复只更新 context rootStore 无法监听变化的问题 #11261

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/amis-core/src/RootRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,15 @@ export class RootRenderer extends React.Component<RootRendererProps> {
this.store.updateLocation(props.location, this.props.env?.parseLocation);
}

let contextChanged = false;
if (props.context !== prevProps.context) {
contextChanged = true;
this.store.updateContext(props.context);
}

// 一定要最后处理,否则 downStream 里面的上层数据 context 还是老的。
if (props.data !== prevProps.data) {
if (props.data !== prevProps.data || contextChanged) {
// context 依赖 data 变化才能触发变动,所以不管 data 变没变都更新一下
this.store.initData(props.data);
}
}
Expand Down
Loading