Moved propTypes and defaultProps as static properties in class components

This commit is contained in:
Alejandro Celaya
2018-08-27 16:53:09 +02:00
parent 47e6e1ca1f
commit 0b089e24de
18 changed files with 168 additions and 209 deletions

View File

@@ -6,17 +6,18 @@ import classnames from 'classnames';
import './SearchField.scss';
const DEFAULT_SEARCH_INTERVAL = 500;
const propTypes = {
onChange: PropTypes.func.isRequired,
className: PropTypes.string,
placeholder: PropTypes.string,
};
const defaultProps = {
className: '',
placeholder: 'Search...',
};
export default class SearchField extends React.Component {
static propTypes = {
onChange: PropTypes.func.isRequired,
className: PropTypes.string,
placeholder: PropTypes.string,
};
static defaultProps = {
className: '',
placeholder: 'Search...',
};
state = { showClearBtn: false, searchTerm: '' };
timer = null;
@@ -64,6 +65,3 @@ export default class SearchField extends React.Component {
);
}
}
SearchField.propTypes = propTypes;
SearchField.defaultProps = defaultProps;