UNPKG

use-basin

Version:

A simple React hook for handling Basin AJAX forms.

28 lines (27 loc) 672 B
import React = require('react'); interface BasinState { submitted: boolean; pending: boolean; error: boolean; } /** * React hook to submit to Basin forms via AJAX. * * * @param id The Basin form ID * @returns The state of the form, and the submit function. * * @example * import useBasin from 'use-basin' * const [state, submit] = useBasin("<basin form id>"); * return ( * <form * onSubmit={(e) => { * e.preventDefault(); * submit(e); * }} * ></form> * ); */ declare function useBasin(id: string): [BasinState, React.FormEventHandler<HTMLFormElement>]; export default useBasin;