Commit 82b10bbc by Vladislav Lagunov

Исправлена ошибка в Debounce

parent e2ed0fac
...@@ -47,7 +47,7 @@ export type State<A> = AutoCompleteState<A> & { ...@@ -47,7 +47,7 @@ export type State<A> = AutoCompleteState<A> & {
// Component // Component
// @ts-ignore Хак для работы дженерик-параметров // @ts-ignore Хак для работы дженерик-параметров
@withStyles(styles) @withStyles(styles)
export default class AutoComplete<A=string> extends React.Component<Props<A>, State<A>> { export default class AutoComplete<A=string> extends React.PureComponent<Props<A>, State<A>> {
static defaultProps = { static defaultProps = {
openOnFocus: true, openOnFocus: true,
openOnClick: true, openOnClick: true,
......
...@@ -24,7 +24,7 @@ export class Debounce<A> extends React.Component<Props<A>, State<A>> { ...@@ -24,7 +24,7 @@ export class Debounce<A> extends React.Component<Props<A>, State<A>> {
callback: Function|null = null; callback: Function|null = null;
componentWillReceiveProps(nextProps: Props<A>) { componentWillReceiveProps(nextProps: Props<A>) {
if ('value' in this.state) this.setState(prev => ({})); if ('value' in this.state) this.setState(prev => ({ value: undefined }));
} }
handleChange = (value) => { handleChange = (value) => {
...@@ -48,7 +48,7 @@ export class Debounce<A> extends React.Component<Props<A>, State<A>> { ...@@ -48,7 +48,7 @@ export class Debounce<A> extends React.Component<Props<A>, State<A>> {
render() { render() {
return React.cloneElement(this.props.children, { return React.cloneElement(this.props.children, {
value: 'value' in this.state ? this.state.value : this.props.children.props.value, value: this.state.value !== undefined ? this.state.value : this.props.children.props.value,
onValueChange: this.handleChange, onValueChange: this.handleChange,
onBlur: this.handleBlur, onBlur: this.handleBlur,
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment