fix(devui): Always run updateTabs on UNSAFE_componentWillReceiveProps. Otherwise, the changes in property tabs might not be reflected on the UI.

This commit is contained in:
hanayashiki 2021-04-25 14:19:54 -07:00
parent a094e3b42c
commit 0e366fccc3
No known key found for this signature in database
GPG Key ID: A67140D398F164A2

View File

@ -24,11 +24,9 @@ export default class Tabs<P> extends Component<TabsProps<P>> {
SelectedComponent?: React.ComponentType<P>;
selector?: () => P;
UNSAFE_componentWillReceiveProps(nextProps: TabsProps<P>) {
if (nextProps.selected !== this.props.selected) {
UNSAFE_componentWillReceiveProps(nextProps: TabsProps<P>): void {
this.updateTabs(nextProps);
}
}
onMouseUp: React.MouseEventHandler<HTMLButtonElement> = (e) => {
e.currentTarget.blur();
@ -38,7 +36,7 @@ export default class Tabs<P> extends Component<TabsProps<P>> {
this.props.onClick(e.currentTarget.value);
};
updateTabs(props: TabsProps<P>) {
updateTabs(props: TabsProps<P>): void {
const tabs = props.tabs;
const selected = props.selected;