import * as React from "react";
import Debounce from "./Debounce";

export interface DebounceFormProps {
  change: (event: React.ChangeEvent<any>) => void;
  children: ((
    props: (event: React.ChangeEvent<any>) => void
  ) => React.ReactNode);
  submit: (event: React.FormEvent<any>) => void;
  time?: number;
}

export const DebounceForm: React.StatelessComponent<DebounceFormProps> = ({
  change,
  children,
  submit,
  time
}) => (
  <Debounce debounceFn={submit} time={time}>
    {debounceFn =>
      children(event => {
        change(event);
        debounceFn();
      })
    }
  </Debounce>
);

import * as React from "react";
import Debounce from "./Debounce";

export interface DebounceFormProps {
  change: (event: React.ChangeEvent<any>, cb?: () => void) => void;
  children: ((
    props: (event: React.ChangeEvent<any>) => void
  ) => React.ReactNode);
  submit: (event: React.FormEvent<any>) => void;
  time?: number;
}

export const DebounceForm: React.StatelessComponent<DebounceFormProps> = ({
  change,
  children,
  submit,
  time
}) => (
  <Debounce debounceFn={submit} time={time}>
    {debounceFn =>
      children(event => {
        change(event, debounceFn);
      })
    }
  </Debounce>
);

Use callback after form's setState
Use callback after form's setState
