Skip to content

Commit

Permalink
fix: resolve issue with tabs continuously re-rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
echoxyc committed Jun 28, 2023
1 parent c10a21e commit e6ab472
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions packages/tabs/src/headers/tab-line-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ export const TabLineHeader = forwardRef<HTMLDivElement, TabHeaderProps>(
childRef.current,
)?.reduce((a, b) => a + b, 0)
const offsetSize = getOffsetSize(_isHorizontalLayout, scrollRef)

setNeedScroll(childrenSize > offsetSize)
}, [_isHorizontalLayout, width, height, tabHeaderChild?.length])

Expand All @@ -161,7 +160,7 @@ export const TabLineHeader = forwardRef<HTMLDivElement, TabHeaderProps>(
)
}, [_isHorizontalLayout, selectedIndex])

const dividerSize = () => {
const dividerSize = useMemo(() => {
const sizeArr = getChildrenSize(_isHorizontalLayout, childRef.current)
let size = 0
const len = sizeArr?.length
Expand All @@ -171,7 +170,7 @@ export const TabLineHeader = forwardRef<HTMLDivElement, TabHeaderProps>(
return size > getOffsetSize(_isHorizontalLayout, scrollRef)
? size
: getOffsetSize(_isHorizontalLayout, scrollRef)
}
},[_isHorizontalLayout])

let [
headerContainer,
Expand Down Expand Up @@ -232,7 +231,7 @@ export const TabLineHeader = forwardRef<HTMLDivElement, TabHeaderProps>(
>
<div css={headerContainer} ref={ref}>
{!_isAhead && (
<div css={applyLineCss(childRef && dividerSize())}>
<div css={applyLineCss(childRef && dividerSize)}>
<div
css={applyBlueLineCss(
blueLineWidth,
Expand Down Expand Up @@ -264,7 +263,7 @@ export const TabLineHeader = forwardRef<HTMLDivElement, TabHeaderProps>(
})}
</div>
{isAhead(tabPosition) && (
<div css={applyLineCss(childRef && dividerSize())}>
<div css={applyLineCss(childRef && dividerSize)}>
<div
css={applyBlueLineCss(
blueLineWidth,
Expand Down

0 comments on commit e6ab472

Please sign in to comment.