fix: delete defaultprops (#37966)

This commit is contained in:
lijianan 2022-10-12 11:39:06 +08:00 committed by GitHub
parent e13dd21a9a
commit 768ab54426
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 19 deletions

View File

@ -196,7 +196,7 @@ class Spin extends React.Component<SpinClassProps, SpinState> {
}
}
const SpinFC: SpinFCType = (props: SpinProps) => {
const SpinFC: SpinFCType = props => {
const { prefixCls: customizePrefixCls } = props;
const { getPrefixCls } = React.useContext(ConfigContext);

View File

@ -557,7 +557,6 @@ const ForwardTable = React.forwardRef(InternalTable) as <RecordType extends obje
type InternalTableType = typeof ForwardTable;
interface TableInterface extends InternalTableType {
defaultProps?: Partial<TableProps<any>>;
SELECTION_COLUMN: typeof SELECTION_COLUMN;
EXPAND_COLUMN: typeof RcTable.EXPAND_COLUMN;
SELECTION_ALL: 'SELECT_ALL';

View File

@ -23,7 +23,6 @@ export interface DirectoryTreeProps<T extends BasicDataNode = DataNode> extends
type DirectoryTreeCompoundedComponent = (<T extends BasicDataNode | DataNode = DataNode>(
props: React.PropsWithChildren<DirectoryTreeProps<T>> & { ref?: React.Ref<RcTree> },
) => React.ReactElement) & {
defaultProps: Partial<React.PropsWithChildren<DirectoryTreeProps<any>>>;
displayName?: string;
};

View File

@ -157,7 +157,6 @@ export interface TreeProps<T extends BasicDataNode = DataNode>
type CompoundedComponent = (<T extends BasicDataNode | DataNode = DataNode>(
props: React.PropsWithChildren<TreeProps<T>> & { ref?: React.Ref<RcTree> },
) => React.ReactElement) & {
defaultProps: Partial<React.PropsWithChildren<TreeProps<any>>>;
TreeNode: typeof TreeNode;
DirectoryTree: typeof DirectoryTree;
};

View File

@ -13,12 +13,6 @@ interface ColorPickerProps {
}
export default class ColorPicker extends Component<ColorPickerProps> {
static defaultProps = {
onChange: noop,
onChangeComplete: noop,
position: 'bottom',
};
static getDerivedStateFromProps(props: ColorPickerProps) {
if ('color' in props) {
return {
@ -43,28 +37,28 @@ export default class ColorPicker extends Component<ColorPickerProps> {
};
handleChange = (color: { hex: string }) => {
const { onChange } = this.props;
const { onChange = noop } = this.props;
this.setState({ color: color.hex });
onChange(color.hex, color);
};
handleChangeComplete = (color: { hex: string }) => {
const { onChangeComplete } = this.props;
const { onChangeComplete = noop } = this.props;
this.setState({ color: color.hex });
onChangeComplete(color.hex);
};
render() {
const { small, position, presetColors } = this.props;
const { small, position = 'bottom', presetColors } = this.props;
const { color, displayColorPicker } = this.state;
const width = small ? 80 : 120;
const styles = {
const styles: Record<PropertyKey, React.CSSProperties> = {
color: {
width: `${width}px`,
height: small ? '16px' : '24px',
borderRadius: '2px',
background: color,
} as React.CSSProperties,
},
swatch: {
padding: '4px',
background: '#fff',
@ -72,22 +66,22 @@ export default class ColorPicker extends Component<ColorPickerProps> {
boxShadow: '0 0 0 1px rgba(0,0,0,.1)',
display: 'inline-block',
cursor: 'pointer',
} as React.CSSProperties,
},
popover: {
position: 'absolute',
zIndex: 10,
} as React.CSSProperties,
},
cover: {
position: 'fixed',
top: '0px',
right: '0px',
bottom: '0px',
left: '0px',
} as React.CSSProperties,
},
wrapper: {
position: 'inherit',
zIndex: 100,
} as React.CSSProperties,
},
};
if (position === 'top') {