From 0a1ba7446f2bebdfb3674ecb3c822014bad9006f Mon Sep 17 00:00:00 2001 From: liaoxuezhi <2698393+2betop@users.noreply.github.com> Date: Wed, 27 Nov 2024 11:27:34 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=8F=AA=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=20context=20rootStore=20=E6=97=A0=E6=B3=95=E7=9B=91?= =?UTF-8?q?=E5=90=AC=E5=8F=98=E5=8C=96=E7=9A=84=E9=97=AE=E9=A2=98=20(#1126?= =?UTF-8?q?1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis-core/src/RootRenderer.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/amis-core/src/RootRenderer.tsx b/packages/amis-core/src/RootRenderer.tsx index 48ba5e8aa..847784e6c 100644 --- a/packages/amis-core/src/RootRenderer.tsx +++ b/packages/amis-core/src/RootRenderer.tsx @@ -101,12 +101,15 @@ export class RootRenderer extends React.Component { 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); } }