import React from 'react';
import debounce from 'lodash-es/debounce';
interface IDebouncedProps {
    [key: string]: any;
}
function deb(wait: number) {
    return (key: string) =>
        function debounced<P>(Comp: React.ComponentClass<P>) {
            class Debounced<F extends Function> extends React.Component<P> {
                method: F & _.Cancelable;
                constructor(props: P & IDebouncedProps) {
                    super(props);
                    this.method = debounce<F>(props[key] as F, wait);
                }
                componentWillUnmount() {
                    this.method.cancel();
                }
                render() {
                    const newProps = Object.assign({}, this.props, {
                        [key]: this.method
                    });
                    return <Comp {...newProps} />;
                }
            }
            return Debounced;
        };
}

export default deb(600);

import React from 'react';
import debounce from 'lodash-es/debounce';
interface IDebouncedProps {
    [key: string]: any;
}
function deb(wait: number) {
    return (key: string) =>
        function debounced<P>(Comp: React.ComponentType<P>) {
            class Debounced<F extends () => void> extends React.Component<P> {
                method: F & _.Cancelable;
                constructor(props: P & IDebouncedProps) {
                    super(props);
                    this.method = debounce<F>(props[key] as F, wait);
                }
                componentWillUnmount() {
                    this.method.flush();
                }
                componentWillReceiveProps(nextProps: P) {
                    if (nextProps[key] !== this.props[key]) {
                        this.method.flush();
                        this.method = debounce<F>(nextProps[key] as F, wait);
                    }
                }
                render() {
                    // tslint:disable-next-line:prefer-object-spread
                    const newProps = Object.assign({}, this.props, {
                        [key]: this.method,
                    });
                    return <Comp {...newProps} />;
                }
            }
            return Debounced;
        };
}
export default deb(600);

Update callback on props change.
Update callback on props change.
