|
26 | 26 |
|
27 | 27 | import * as React from 'react'; |
28 | 28 | import classNames from 'classnames'; |
| 29 | +import shallowEqual from 'shallowequal'; |
29 | 30 | import warning from 'rc-util/lib/warning'; |
30 | 31 | import ResizeObserver from 'rc-resize-observer'; |
31 | 32 | import getScrollBarSize from 'rc-util/lib/getScrollBarSize'; |
@@ -78,12 +79,20 @@ interface MemoTableContentProps { |
78 | 79 | children: React.ReactNode; |
79 | 80 | pingLeft: boolean; |
80 | 81 | pingRight: boolean; |
| 82 | + props: any; |
81 | 83 | } |
82 | 84 | const MemoTableContent = React.memo<MemoTableContentProps>( |
83 | 85 | ({ children }) => children as React.ReactElement, |
84 | | - // No additional render when pinged status change. |
85 | | - // This is not a bug. |
86 | | - (prev, next) => prev.pingLeft !== next.pingLeft || prev.pingRight !== next.pingRight, |
| 86 | + |
| 87 | + (prev, next) => { |
| 88 | + if (!shallowEqual(prev.props, next.props)) { |
| 89 | + return false; |
| 90 | + } |
| 91 | + |
| 92 | + // No additional render when pinged status change. |
| 93 | + // This is not a bug. |
| 94 | + return prev.pingLeft !== next.pingLeft || prev.pingRight !== next.pingRight; |
| 95 | + }, |
87 | 96 | ); |
88 | 97 |
|
89 | 98 | export interface TableProps<RecordType = unknown> extends LegacyExpandableProps<RecordType> { |
@@ -627,7 +636,7 @@ function Table<RecordType extends DefaultRecordType>(props: TableProps<RecordTyp |
627 | 636 | ref={fullTableRef} |
628 | 637 | {...ariaProps} |
629 | 638 | > |
630 | | - <MemoTableContent pingLeft={pingedLeft} pingRight={pingedRight}> |
| 639 | + <MemoTableContent pingLeft={pingedLeft} pingRight={pingedRight} props={props}> |
631 | 640 | {title && <Panel className={`${prefixCls}-title`}>{title(mergedData)}</Panel>} |
632 | 641 | <div className={`${prefixCls}-container`}>{groupTableNode}</div> |
633 | 642 | {footer && <Panel className={`${prefixCls}-footer`}>{footer(mergedData)}</Panel>} |
|
0 commit comments