@beekai/react
TypeScript icon, indicating that this package has built-in type declarations

0.4.1 • Public • Published

logo

beekai-react

This library contains hooks to work with beekai form. It's a wrapper with react-hook-form

Usage

const {
  submit,
  onSubmit,
  register,
  handleSubmit,
  submissionId,
  formState: { errors }
} = useBeikai({
  formId: 'beekai-form-id' // BEEKAI form applicaiton id
})

if (submissionId) {
  return <p>Thank you! Submission Id is: {submissionId}</p>
}

if (errors?.serverError) {
  return <p>Server error and submission failed.</p>
}

// native submit
return (
  <form onSubmit={onSubmit}>
    <input {...register('data')} />
  </form>
}

// custom submit
return (
  <form onSubmit={handleSubmit(async (data) => {
    await submit(data)
  })}>
    <input {...register('data')} />
  </form>
}

Readme

Keywords

none

Package Sidebar

Install

npm i @beekai/react

Weekly Downloads

0

Version

0.4.1

License

MIT

Unpacked Size

24.3 kB

Total Files

5

Last publish

Collaborators

  • bluebill1049