import { useCallback } from 'react' import { useSend } from '.' import useSendButtonCaption from './useSendButtonCaption' function useSendWithButton>( initial: string, result: string, singular?: boolean, ...useSendArgs: Parameters> ) { const { doSend, loading, error } = useSend(...useSendArgs) const { update, ...button } = useSendButtonCaption(initial, loading, error, result, singular) const doSendWithButton = useCallback(async (...args: Parameters) => { const data = await doSend(...args) update(data) return data }, [doSend, update]) return { doSend: doSendWithButton, button } } export default useSendWithButton