Socket
Socket
Sign inDemoInstall

@beekai/react

Package Overview
Dependencies
0
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.2 to 0.1.0

6

CHANGELOG.md
# @beekai/react
## 0.1.0
### Minor Changes
- 1eb3590e7: - add new submissionId prop from useForm hook
## 0.0.2

@@ -4,0 +10,0 @@

2

package.json
{
"name": "@beekai/react",
"version": "0.0.2",
"version": "0.1.0",
"license": "MIT",

@@ -5,0 +5,0 @@ "publishConfig": {

@@ -10,6 +10,21 @@ <img src="https://www.beekai.com/marketing/og.png" alt="logo" />

```tsx
const { submit, onSubmit, register, handleSubmit } = useBeikai({
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

@@ -16,0 +31,0 @@ return (

@@ -0,1 +1,2 @@

import * as React from 'react';
import {

@@ -21,4 +22,6 @@ useForm as hookFormUseForm,

submit: SubmitHandler<TFieldValues>;
submissionId: string;
onSubmit: (e: React.BaseSyntheticEvent) => void;
} {
const [submissionId, setSubmissionId] = React.useState('');
const { formId, ...rest } = props;

@@ -32,3 +35,3 @@ const methods = hookFormUseForm<TFieldValues, TContext>(rest);

try {
const result = await fetch('https://beekai.com/api/v1/submit', {
const response = await fetch('https://beekai.com/api/v1/submit', {
method: 'POST',

@@ -39,6 +42,8 @@ body: JSON.stringify({ form_id: props.formId, data }),

if (result.status !== 200) {
if (response.status !== 200) {
const data = await response.json();
setSubmissionId(data.id);
methods.setError('serverError' as FieldPath<TFieldValues>, {
type: 'server',
message: `Request has failed with status code ${result.status}`,
message: `Request has failed with status code ${response.status}`,
});

@@ -59,2 +64,3 @@ }

submit,
submissionId,
onSubmit: (e) => {

@@ -61,0 +67,0 @@ methods.clearErrors();

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc