Skip to content

Commit

Permalink
chore: 重复代码抽离
Browse files Browse the repository at this point in the history
  • Loading branch information
zzzJH committed Apr 9, 2019
1 parent e9b645e commit adc6ef3
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/SelectTrigger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,11 @@ export default class SelectTrigger extends React.Component<
}

public componentWillUnmount() {
if (this.rafInstance) {
raf.cancel(this.rafInstance);
}
this.cancelRafInstance();
}

public setDropdownWidth = () => {
if (this.rafInstance) {
raf.cancel(this.rafInstance);
}
this.cancelRafInstance();
this.rafInstance = raf(() => {
const dom = ReactDOM.findDOMNode(this) as HTMLDivElement;
const width = dom.offsetWidth;
Expand All @@ -139,6 +135,12 @@ export default class SelectTrigger extends React.Component<
});
};

public cancelRafInstance = () => {
if (this.rafInstance) {
raf.cancel(this.rafInstance);
}
};

public getInnerMenu = () => {
return this.dropdownMenuRef && this.dropdownMenuRef.menuRef;
};
Expand Down

0 comments on commit adc6ef3

Please sign in to comment.