Skip to content

Commit

Permalink
chore: use internal hook
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Aug 17, 2023
1 parent 015ff4e commit 9a8cf51
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ export interface TableProps<RecordType = unknown>
// Used for antd table transform column with additional column
transformColumns?: (columns: ColumnsType<RecordType>) => ColumnsType<RecordType>;

/**
* @private Internal usage, may remove by refactor.
*
* !!! DO NOT USE IN PRODUCTION ENVIRONMENT !!!
*/
// Force trade scrollbar as 0 size.
hideScrollColumn?: boolean;

/**
* @private Internal usage, may remove by refactor.
*
Expand Down Expand Up @@ -186,6 +194,7 @@ function Table<RecordType extends DefaultRecordType>(tableProps: TableProps<Reco
internalHooks,
transformColumns,
internalRefs,
hideScrollColumn,

sticky,
} = props;
Expand Down Expand Up @@ -238,7 +247,6 @@ function Table<RecordType extends DefaultRecordType>(tableProps: TableProps<Reco
}, [rowKey]);

const customizeScrollBody = getComponent(['body']) as CustomizeScrollBody<RecordType>;
const isCustomizeScrollBodyFn = typeof customizeScrollBody === 'function';

// ====================== Hover =======================
const [startRow, endRow, onHover] = useHover();
Expand Down Expand Up @@ -442,7 +450,7 @@ function Table<RecordType extends DefaultRecordType>(tableProps: TableProps<Reco
const [supportSticky, setSupportSticky] = React.useState(true); // Only IE not support, we mark as support first

React.useEffect(() => {
if (!isCustomizeScrollBodyFn) {
if (!hideScrollColumn || !useInternalHooks) {
if (scrollBodyRef.current instanceof Element) {
setScrollbarSize(getTargetScrollBarSize(scrollBodyRef.current).width);
} else {
Expand Down Expand Up @@ -542,18 +550,14 @@ function Table<RecordType extends DefaultRecordType>(tableProps: TableProps<Reco
<caption className={`${prefixCls}-caption`}>{caption}</caption>
) : undefined;

if (process.env.NODE_ENV !== 'production' && isCustomizeScrollBodyFn && hasData && !fixHeader) {
warning(false, '`components.body` with render props is only work on `scroll.y`.');
}

const dataProps = pickAttrs(props, { data: true });
const ariaProps = pickAttrs(props, { aria: true });

if (fixHeader || isSticky) {
// >>>>>> Fixed Header
let bodyContent: React.ReactNode;

if (isCustomizeScrollBodyFn) {
if (typeof customizeScrollBody === 'function') {
bodyContent = customizeScrollBody(mergedData, {
scrollbarSize,
ref: scrollBodyRef,
Expand Down

0 comments on commit 9a8cf51

Please sign in to comment.