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