
Security News
How Enterprise Security Is Adapting to AI-Accelerated Threats
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.
@bedrockstreaming/form-context
Advanced tools
form-context is a React reducer solution to manage steps.
Since we are using react-hook-form to persist data locally, we are only storing the form data and step information on each step submission.
:::note
You can avoid to store any form data if you wish
:::
npm install @bedrockstreaming/form-context
import { useEffect } from 'react';
import { FormBuilder } from '@bedrockstreaming/form-builder';
import {
getCurrentStepIndex,
isLastStep,
resetForm,
initForm,
setNextStep,
useFormsDispatch,
useFormsState,
FormProvider,
} from '@bedrockstreaming/form-context';
import { schema, formId } from './path/to/my/config';
import { fooSubmitAction } from '<my-app-module>';
const FooForm = () => {
const dispatch = useFormsDispatch();
const state = useFormsState();
const currentStepIndex = getCurrentStepIndex(formId)(state);
const shouldSubmit = isLastStepSelector(formId)(state);
const previousValues = getFormData(formId)(state);
useEffect(() => {
dispatch(initForm(formId, schema));
}, [dispatch]);
const handleSubmit = useSubmit(formId);
const handleNextStep = (fieldsValues: FieldValues) => {
dispatch(updateFormData(formId, fieldsValues));
dispatch(setNextStep(formId));
};
const handleSubmit = (fieldValues: FieldValues) => {
if (shouldSubmit) {
fooSubmit(fieldValues);
dispatch(resetForm(formId));
} else {
dispatch(setNextStep(formId));
}
};
return (
<FormBuilder
dictionary={dictionary}
schema={schema}
onSubmit={handleSubmit}
handleNextStep={handleNextStep}
currentStepIndex={currentStepIndex}
/>
);
};
export const FormContainer = () => {
return (
<FormsProvider>
<Form />
</FormsProvider>
);
};
Run nx test form-context to execute the unit tests via Jest.
FAQs
`form-context` is a React reducer solution to manage steps.
The npm package @bedrockstreaming/form-context receives a total of 3 weekly downloads. As such, @bedrockstreaming/form-context popularity was classified as not popular.
We found that @bedrockstreaming/form-context demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 8 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.