fix: 修复获取 context 数据过时的问题

This commit is contained in:
2betop 2024-10-31 11:02:37 +08:00
parent 1b17c395ae
commit cd1093f38b

View File

@ -95,10 +95,6 @@ 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);
}
@ -106,6 +102,11 @@ export class RootRenderer extends React.Component<RootRendererProps> {
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) {