mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-04 00:49:39 +08:00
⚡ improve getDerivedStateFromProps return value
This commit is contained in:
parent
d20b5fe9f5
commit
c7b9eee709
@ -40,7 +40,6 @@ export default function createPicker(TheCalendar: React.ComponentClass): any {
|
|||||||
}
|
}
|
||||||
if ('value' in nextProps) {
|
if ('value' in nextProps) {
|
||||||
state.value = nextProps.value;
|
state.value = nextProps.value;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
nextProps.value !== prevState.value ||
|
nextProps.value !== prevState.value ||
|
||||||
(!open && nextProps.value !== prevState.showDate)
|
(!open && nextProps.value !== prevState.showDate)
|
||||||
@ -48,7 +47,7 @@ export default function createPicker(TheCalendar: React.ComponentClass): any {
|
|||||||
state.showDate = nextProps.value;
|
state.showDate = nextProps.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return state;
|
return Object.keys(state).length > 0 ? state : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private input: any;
|
private input: any;
|
||||||
|
@ -51,7 +51,6 @@ class Tag extends React.Component<TagProps, TagState> {
|
|||||||
closed: !nextProps.visible,
|
closed: !nextProps.visible,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return newState;
|
return newState;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -16,9 +16,12 @@ export default class ColorPicker extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static getDerivedStateFromProps(props) {
|
static getDerivedStateFromProps(props) {
|
||||||
return {
|
if ('color' in props) {
|
||||||
color: props.color,
|
return {
|
||||||
};
|
color: props.color,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
|
Loading…
Reference in New Issue
Block a user