- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 621
avoiding closure problems #1352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
c30f805
              05c1ed2
              771c7e8
              86f6450
              015927a
              8499952
              c3d6bf7
              c02d9a6
              0a8f306
              ab7bcad
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -30,7 +30,9 @@ const data = [ | |
| { key: 3, name: 'Jime', age: 35 }, | ||
| ]; | ||
|  | ||
| // 自定义 MeasureRow 渲染,隐藏弹层内容 | ||
| // 注意,这个 measureRow 实际上是一个 <tr> 标签 | ||
| // 按照 html 规范,tr 的父元素必须是 table、thead、tbody、tfoot 标签,子元素必须是 th、td 标签 | ||
| // 因此这里我们用一个 div 包裹是不对的,在控制台中会报错 | ||
| const measureRowRender: TableProps['measureRowRender'] = measureRow => ( | ||
| <div style={{ display: 'none' }}>{measureRow}</div> | ||
|          | ||
| ); | ||
|  | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -157,31 +157,16 @@ const FixedHolder = React.forwardRef<HTMLDivElement, FixedHeaderProps<any>>((pro | |
|  | ||
| const mergedColumnWidth = useColumnWidth(colWidths, columCount); | ||
|  | ||
| const colGroupNode = useMemo(() => { | ||
| const mayBeEmpty = useMemo<boolean>(() => { | ||
|         
                  li-jia-nan marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| // use original ColGroup if no data or no calculated column width, otherwise use calculated column width | ||
| // Return original colGroup if no data, or mergedColumnWidth is empty, or all widths are falsy | ||
| if ( | ||
| return ( | ||
| noData || | ||
| !mergedColumnWidth || | ||
| mergedColumnWidth.length === 0 || | ||
| !mergedColumnWidth.length || | ||
| mergedColumnWidth.every(width => !width) | ||
| ) { | ||
| return ColGroup; | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ColGroup 是一个函数,直接渲染到 UI 会报错,这里应该返回 null | ||
| } | ||
| return ( | ||
| <ColGroup | ||
| colWidths={[...mergedColumnWidth, combinationScrollBarSize]} | ||
| columCount={columCount + 1} | ||
| columns={flattenColumnsWithScrollbar} | ||
| /> | ||
| ); | ||
| }, [ | ||
| noData, | ||
| mergedColumnWidth, | ||
| combinationScrollBarSize, | ||
| columCount, | ||
| flattenColumnsWithScrollbar, | ||
| ]); | ||
| }, [noData, mergedColumnWidth]); | ||
|  | ||
|         
                  li-jia-nan marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| return ( | ||
| <div | ||
|  | @@ -203,7 +188,13 @@ const FixedHolder = React.forwardRef<HTMLDivElement, FixedHeaderProps<any>>((pro | |
| width: scrollX, | ||
| }} | ||
| > | ||
| {colGroupNode} | ||
| {mayBeEmpty ? null : ( | ||
| <ColGroup | ||
| colWidths={[...mergedColumnWidth, combinationScrollBarSize]} | ||
| columCount={columCount + 1} | ||
| columns={flattenColumnsWithScrollbar} | ||
| /> | ||
| )} | ||
| {children({ | ||
| ...restProps, | ||
| stickyOffsets: headerStickyOffsets, | ||
|         
                  li-jia-nan marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
|  | ||
Uh oh!
There was an error while loading. Please reload this page.