FormBuilder with initialForm prop breaks React state updates
@olgabann is already working on this.
Since Sep 25, 2024.
Assessment
This issue has not been assessed yet.
Description
Describe the bug
FormBuilder component causes React to not trigger state updates when initialForm prop is given a schema JSON. As warned in the documentation, I made sure the value is a stable reference by importing a constant JSON file.
To Reproduce
import { useState } from 'react';
import { FormBuilder, FormType } from '@formio/react';
import jsonData from '@/formSchemas/myForm.json';
const MyFormBuilder = () => {
const [schema, setSchema] = useState<FormType>(jsonData as FormType);
const onFormChange = (schema: FormType) => {
setSchema(schema);
};
return (
<div className="grid grid-cols-3">
<div className="col-span-2">
<FormBuilder initialForm={jsonData as FormType} onChange={onFormChange} />
</div>
<div className="schema-preview">
<pre className="bg-slate-500 text-white p-2 max-h-[300px] overflow-auto">
{JSON.stringify(schema, null, 2)}
</pre>
</div>
</div>
);
};
Expected behavior
The schema-preview section should update when a component is dragged into the builder and saved.
- Dominant language
- TypeScript
- Stars
- 371
- Forks
- 309
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from formio/react
-
Difficulty 3/5 1-2 days Newbie friendliness 64/100
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
-
onChange `modified` property remains false when file component is updatedMay be free again @ZenMasterJacob20011 claimed this 295 days ago, and no pull request is open. Open
-
FormBuilder onChange callback not triggered when options prop is providedMay be free again @Victoriya25 claimed this 337 days ago, and no pull request is open. Open
-
FormBuilder with OnChange broke textareaMay be free again @lane-formio claimed this 309 days ago, and no pull request is open. Open
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
milind-soni/OpenMausBot#6730 ·
Maintainers usually reply within 1 day
-
`@angular/[email protected]` depends on vulnerable Vite 7.3.7 - GHSA-p4f5-76q4-ffq7 (Critical RCE)Openarea: @angular/build
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
angular/angular-cli#34764 ·
Maintainers usually reply within 1 day
-
status/need-triage
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
google-gemini/gemini-cli#30384 · 1 comment ·
Maintainers usually reply within 1 day
-
P2
Difficulty 1/5 Under an hour Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
area:image documentation good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day