1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-05 08:53:14 +00:00

remove react old defaultProps (#7576)

This commit is contained in:
Michael An
2025-03-10 14:27:08 +08:00
committed by GitHub
parent 00707d1d05
commit 55719ccbdf
43 changed files with 214 additions and 438 deletions

View File

@@ -54,47 +54,17 @@ Option.propTypes = {
}),
};
export default class SeahubSelect extends React.Component {
static propTypes = {
isMulti: PropTypes.bool,
options: PropTypes.array.isRequired,
value: PropTypes.oneOfType([PropTypes.object, PropTypes.array, PropTypes.string]),
isSearchable: PropTypes.bool,
isClearable: PropTypes.bool,
placeholder: PropTypes.string,
classNamePrefix: PropTypes.string,
className: PropTypes.string,
form: PropTypes.string,
onChange: PropTypes.func.isRequired,
menuPortalTarget: PropTypes.string,
menuPosition: PropTypes.string,
noOptionsMessage: PropTypes.func,
innerRef: PropTypes.object,
isDisabled: PropTypes.bool,
};
static defaultProps = {
options: [],
value: {},
isDisabled: false,
isSearchable: true,
isClearable: true,
placeholder: '',
isMulti: false,
menuPortalTarget: '.modal',
noOptionsMessage: () => {
return null;
},
};
class SeahubSelect extends React.Component {
getMenuPortalTarget = () => {
return document.querySelector(this.props.menuPortalTarget);
const { menuPortalTarget = '.modal' } = this.props;
return document.querySelector(menuPortalTarget);
};
render() {
const { options, onChange, value, isSearchable, placeholder, isMulti, menuPosition, isClearable, noOptionsMessage,
classNamePrefix, innerRef, isDisabled, form, className } = this.props;
const { options = [], onChange, value = {}, isSearchable = true, placeholder = '',
isMulti = false, menuPosition, isClearable = true, noOptionsMessage = (() => { return null; }),
classNamePrefix, innerRef, isDisabled = false, form, className } = this.props;
return (
<Select
@@ -121,3 +91,23 @@ export default class SeahubSelect extends React.Component {
);
}
}
SeahubSelect.propTypes = {
isMulti: PropTypes.bool,
options: PropTypes.array.isRequired,
value: PropTypes.oneOfType([PropTypes.object, PropTypes.array, PropTypes.string]),
isSearchable: PropTypes.bool,
isClearable: PropTypes.bool,
placeholder: PropTypes.string,
classNamePrefix: PropTypes.string,
className: PropTypes.string,
form: PropTypes.string,
onChange: PropTypes.func.isRequired,
menuPortalTarget: PropTypes.string,
menuPosition: PropTypes.string,
noOptionsMessage: PropTypes.func,
innerRef: PropTypes.object,
isDisabled: PropTypes.bool,
};
export default SeahubSelect;