Skip to content

Commit

Permalink
fix: 修复获取 context 数据过时的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
2betop committed Oct 31, 2024
1 parent 1b17c39 commit cd1093f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/amis-core/src/RootRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,18 @@ export class RootRenderer extends React.Component<RootRendererProps> {
componentDidUpdate(prevProps: RootRendererProps) {
const props = this.props;

if (props.data !== prevProps.data) {
this.store.initData(props.data);
}

if (props.location !== prevProps.location) {
this.store.updateLocation(props.location, this.props.env?.parseLocation);
}

if (props.context !== prevProps.context) {
this.store.updateContext(props.context);
}

// 一定要最后处理,否则 downStream 里面的上层数据 context 还是老的。
if (props.data !== prevProps.data) {
this.store.initData(props.data);
}
}

componentDidCatch(error: any, errorInfo: any) {
Expand Down

0 comments on commit cd1093f

Please sign in to comment.