From 85d4c949d96493ba291f5157d948fbd1ac023e2e Mon Sep 17 00:00:00 2001 From: chenwenhao Date: Mon, 10 Feb 2025 11:46:07 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20#11535=20crud=E7=9A=84source?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E5=90=8E=E5=88=86=E9=A1=B5=E5=A4=B1=E6=95=88?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis/src/renderers/Table/index.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/amis/src/renderers/Table/index.tsx b/packages/amis/src/renderers/Table/index.tsx index b78749b281a..fe44a002649 100644 --- a/packages/amis/src/renderers/Table/index.tsx +++ b/packages/amis/src/renderers/Table/index.tsx @@ -703,6 +703,10 @@ export default class Table extends React.Component { const value = getPropValue(props, (props: TableProps) => props.items); let rows: Array = []; let updateRows = false; + const resolved = resolveVariableAndFilter(source, props.data, '| raw'); + const prev = prevProps + ? resolveVariableAndFilter(source, prevProps.data, '| raw') + : null; // 要严格比较前后的value值,否则某些情况下会导致循环update无限渲染 if ( @@ -711,16 +715,12 @@ export default class Table extends React.Component { !isEqual( getPropValue(prevProps, (props: TableProps) => props.items), value - )) + ) || + resolved !== prev) ) { updateRows = true; rows = value; } else if (typeof source === 'string') { - const resolved = resolveVariableAndFilter(source, props.data, '| raw'); - const prev = prevProps - ? resolveVariableAndFilter(source, prevProps.data, '| raw') - : null; - if (prev === resolved) { updateRows = false; } else { From d3acfe650f1a9f2986e5a4a86740e8b1b268ffbd Mon Sep 17 00:00:00 2001 From: chenwenhao Date: Wed, 12 Feb 2025 20:18:50 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20#11535=20crud=E7=9A=84source?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E5=90=8E=E5=88=86=E9=A1=B5=E5=A4=B1=E6=95=88?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis/src/renderers/Table/index.tsx | 25 +++++++++++---------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/packages/amis/src/renderers/Table/index.tsx b/packages/amis/src/renderers/Table/index.tsx index fe44a002649..9afa5816cdb 100644 --- a/packages/amis/src/renderers/Table/index.tsx +++ b/packages/amis/src/renderers/Table/index.tsx @@ -703,24 +703,25 @@ export default class Table extends React.Component { const value = getPropValue(props, (props: TableProps) => props.items); let rows: Array = []; let updateRows = false; - const resolved = resolveVariableAndFilter(source, props.data, '| raw'); - const prev = prevProps - ? resolveVariableAndFilter(source, prevProps.data, '| raw') - : null; // 要严格比较前后的value值,否则某些情况下会导致循环update无限渲染 - if ( - Array.isArray(value) && - (!prevProps || + if (Array.isArray(value)) { + if ( + !prevProps || !isEqual( getPropValue(prevProps, (props: TableProps) => props.items), value - ) || - resolved !== prev) - ) { - updateRows = true; - rows = value; + ) + ) { + updateRows = true; + rows = value; + } } else if (typeof source === 'string') { + const resolved = resolveVariableAndFilter(source, props.data, '| raw'); + const prev = prevProps + ? resolveVariableAndFilter(source, prevProps.data, '| raw') + : null; + if (prev === resolved) { updateRows = false; } else {