Skip to content

Commit

Permalink
type(Tabs): fix type error.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Sep 19, 2023
1 parent 7a63a65 commit d1c3fef
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@
"husky": "~8.0.0",
"kkt": "^7.5.2",
"lerna": "^7.3.0",
"lint-staged": "^13.0.3",
"prettier": "~2.8.0",
"lint-staged": "^14.0.1",
"prettier": "^3.0.3",
"react": "~18.2.0",
"react-dom": "~18.2.0",
"react-test-renderer": "~18.2.0",
Expand Down
27 changes: 14 additions & 13 deletions packages/react-tabs/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export * from './Pane';

Tabs.Pane = Pane;

let labelWidth: number = 0;
export interface TabsProps extends IProps, HTMLDivProps {
prefixCls?: string;
activeKey?: string;
Expand Down Expand Up @@ -52,7 +51,7 @@ export default function Tabs(props: TabsProps) {
const deviation = 15;

const [nodes, nodesSet] = useState<any>();
const divContentRef = useCallback((node) => {
const divContentRef = useCallback((node: HTMLDivElement) => {
if (node !== null) {
nodesSet(nodes);
node.addEventListener('scroll', (e: any) => {
Expand All @@ -66,18 +65,21 @@ export default function Tabs(props: TabsProps) {
}
}, []);

const divNavRef = useCallback((node, key: number, itemKey: React.Key | null, activeKey) => {
if (node !== null) {
// node.addEventListener('click', (e: any) => {
// activeItem.current = node;
// });
divNavWidthChange(node.getBoundingClientRect().width, key);
const divNavRef = useCallback(
(node: HTMLDivElement | null, key: number, itemKey: React.Key | null, activeKey?: string) => {
if (node !== null) {
// node.addEventListener('click', (e: any) => {
// activeItem.current = node;
// });
divNavWidthChange(node.getBoundingClientRect().width, key);

if (itemKey === activeKey) {
activeItem.current = node;
if (itemKey === activeKey) {
activeItem.current = node;
}
}
}
}, []);
},
[],
);

const divNavWidthChange = (width: number, index: number) => {
let curWidth = 0;
Expand Down Expand Up @@ -109,7 +111,6 @@ export default function Tabs(props: TabsProps) {
useEffect(() => calcSlideStyle(), [activeKey]);
function calcSlideStyle() {
if (activeItem.current && type === 'line') {
labelWidth = activeItem.current.clientWidth;
setSlideStyle({
width: activeItem.current.clientWidth,
left: activeItem.current.offsetLeft,
Expand Down
2 changes: 1 addition & 1 deletion packages/uiw/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"react-dom": ">=16.9.0"
},
"dependencies": {
"@babel/runtime": "~7.20.0",
"@babel/runtime": "~7.22.15",
"@types/react": "~18.2.0",
"@types/react-dom": "~18.2.0",
"@uiw/formatter": "~2.0.0",
Expand Down

0 comments on commit d1c3fef

Please sign in to comment.