Skip to content

Commit

Permalink
fix: #519
Browse files Browse the repository at this point in the history
  • Loading branch information
yangpan authored and yangpan committed Dec 9, 2020
1 parent 40dc733 commit bed54d4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions components/tabs/Tabs.tsx
Original file line number Diff line number Diff line change
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
2 changes: 1 addition & 1 deletion components/tabs/demo.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ const Demo = () => {
const [value, setValue] = useState(0);

return (
<Tabs scrollable value={value} onChange={setValue} direction="vertical" className="custom-height">
<Tabs value={value} onChange={setValue} direction="vertical" className="custom-height">
<Panel title="选项卡1">
<div className="content">选项卡1内容</div>
</Panel>
Expand Down

0 comments on commit bed54d4

Please sign in to comment.