Skip to content

Commit

Permalink
reactor(Table): 移除Table中使用的即将废弃的 React API (#753)
Browse files Browse the repository at this point in the history
  • Loading branch information
cuilanxin committed Apr 8, 2022
1 parent 89da44a commit 4e89936
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/react-table/src/ThComponent.tsx
@@ -1,5 +1,4 @@
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import { TableColumns, TableProps, LocationWidth } from './';
import { locationFixed } from './util';

Expand All @@ -14,10 +13,10 @@ interface ThComponentProps<T> {
updateLocation: (params: LocationWidth, index: string, key: string, colSpan?: number) => void;
}
export default class ThComponent<T> extends Component<ThComponentProps<T>> {
wrapper = React.createRef<HTMLTableCellElement>();
componentDidMount() {
const rect = ReactDOM.findDOMNode(this) as Element;
this.props.updateLocation(
{ width: rect.getBoundingClientRect().width },
{ width: this.wrapper.current!.getBoundingClientRect().width },
`${this.props.rowNum}${this.props.colNum}`,
this.props.item.key!,
this.props.item.colSpan,
Expand All @@ -37,6 +36,7 @@ export default class ThComponent<T> extends Component<ThComponentProps<T>> {
}
return (
<th
ref={this.wrapper}
key={colNum}
{...thProps}
style={{ ...thProps.style, ...locationFixed(fixed, locationWidth, `${rowNum}${colNum}`) }}
Expand Down

0 comments on commit 4e89936

Please sign in to comment.