Skip to content

Commit

Permalink
Merge pull request #520 from Yang03/tabs
Browse files Browse the repository at this point in the history
fix: #519
  • Loading branch information
JeromeLin committed Dec 9, 2020
2 parents 4e2c4f9 + b977336 commit edf0151
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions components/tabs/Tabs.tsx
Expand Up @@ -61,14 +61,18 @@ export default class Tabs extends PureComponent<TabsProps, TabsStates> {
}

componentDidMount() {
this.calculateLineWidth();
this.calculateScorllLeftLocation();
const { children } = this.props;
if (React.Children.count(children)) {
this.calculateLineWidth();
this.calculateScorllLeftLocation();
}
}

componentDidUpdate(prevstate) {
const { value: prevValue } = prevstate;
const { value: prevValue, children: prevChild } = prevstate;
const { value } = this.state;
if (prevValue !== value) {
const { children } = this.props;
if (prevValue !== value || prevChild !== children) {
this.calculateLineWidth();
}
this.calculateScorllLeftLocation();
Expand Down

0 comments on commit edf0151

Please sign in to comment.