FormBuilder with initialForm prop breaks React state updates

オープン
#576 コメント 2 件 リアクション 5 件 担当者 1 名 GitHub で見る

@olgabann がすでに取り組んでいます。

2024年9月25日 から。

評価

この issue はまだ評価されていません。

説明

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.

主要言語
TypeScript
スター
371
フォーク
309
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

formio/react のほかの issue

formio/react の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。