# Integrate Form Editor in React JS Typescript

**URL:** <https://forum.bpmn.io/t/integrate-form-editor-in-react-js-typescript/10993>\
**Category:** Developers\
**Created:** [May 10, 2024, 9:20am UTC](https://forum.bpmn.io/t/integrate-form-editor-in-react-js-typescript/10993 "2024-05-10T09:20:23Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexander.Zeiler](https://forum.bpmn.io/letter_avatar_proxy/v4/letter/a/ecd19e/32.png) [@Alexander.Zeiler](https://forum.bpmn.io/u/Alexander.Zeiler)\
**Post date:** [May 10, 2024, 9:20am UTC](https://forum.bpmn.io/t/integrate-form-editor-in-react-js-typescript/10993/1 "2024-05-10T09:20:23Z")

</div>

Hello!

I’m currently trying to integrate version 1.7.3 of the Form.js editor into my React JS project.

My import looks like this:

```auto
import { FormEditor } from "@bpmn-io/form-js";

import "@bpmn-io/form-js/dist/assets/form-js.css";
import "@bpmn-io/form-js/dist/assets/form-js-editor.css";

```

My code looks like this:

```auto
    const divRef = useRef<HTMLDivElement>(null);
    const formEditor = useRef<FormEditor | null>(null);
    const [error, setError] = useState<unknown>();

    useEffect(() => {
        const div = divRef.current;
        if (!div) return;
        formEditor.current = new FormEditor({ container: div });
        return () => {
            formEditor.current?.destroy();
            formEditor.current = null;
        };
    }, []);

    useEffect(() => {
        const editor = formEditor.current;
        if (editor) {
            const handler = () => {
                onChange(JSON.stringify(editor.getSchema()));
                void onBlur();
            };
            editor.on("changed", handler);
            return () => {
                editor.off("changed", handler);
            };
        }
    }, [onBlur, onChange]);

    useEffect(() => {
        const editor = formEditor.current;
        if (editor && JSON.stringify(editor.getSchema()) !== value) {
            editor
                .importSchema(JSON.parse(value))
                .then(() => {
                    onChange(JSON.stringify(editor.getSchema()));
                    void onBlur();
                })
                .catch(setError);
        }
    });

```

The integration works without any issues. The editor is displayed, and it can be interacted with. However, I’m encountering some peculiar display errors at times.

When I drag a component into the Components section, it disappears from the editor. However, the component doesn’t disappear from the schema. If I reload the editor, it reappears.

Could it possibly be related to my integration or to the rendering of React?

---

<div class="post-metadata">

**Author:** ![Alexander.Zeiler](https://forum.bpmn.io/letter_avatar_proxy/v4/letter/a/ecd19e/32.png) [@Alexander.Zeiler](https://forum.bpmn.io/u/Alexander.Zeiler)\
**Post date:** [May 13, 2024, 9:44am UTC](https://forum.bpmn.io/t/integrate-form-editor-in-react-js-typescript/10993/2 "2024-05-13T09:44:36Z")

</div>

I discovered that it might be related to the npm package. After trying out the `<script src="https://unpkg.com/@bpmn-io/form-js@1.7.3/dist/form-editor.umd.js"></script>` variant, it worked. I’m still not exactly sure if it’s due to my webpack config - I’m excluding all node\_modules - or really the package itself.

---

<div class="post-metadata">

**Author:** ![vsgoulart](https://forum.bpmn.io/letter_avatar_proxy/v4/letter/v/977dab/32.png) [@vsgoulart](https://forum.bpmn.io/u/vsgoulart)\
**Post date:** [May 22, 2024, 1:22pm UTC](https://forum.bpmn.io/t/integrate-form-editor-in-react-js-typescript/10993/3 "2024-05-22T13:22:56Z")

</div>

Hi @Alexander.Zeiler ,

sorry we missed your post and took so long to answer.

At first everything looks good with your code, could you post a reproduction on [CodeSandbox](https://codesandbox.io/) so we have an isolated environment with the possible bug?

---

<div class="post-metadata">

**Author:** ![Alexander.Zeiler](https://forum.bpmn.io/letter_avatar_proxy/v4/letter/a/ecd19e/32.png) [@Alexander.Zeiler](https://forum.bpmn.io/u/Alexander.Zeiler)\
**Post date:** [May 22, 2024, 2:27pm UTC](https://forum.bpmn.io/t/integrate-form-editor-in-react-js-typescript/10993/4 "2024-05-22T14:27:36Z")

</div>

Hi, thank you for you answer.

Here is the reproduction: [CodeSandbox](https://codesandbox.io/p/devbox/62yfz5?migrateFrom=66fr8k&embed=1&file=%2Fsrc%2Fstyles.css&layout=%257B%2522sidebarPanel%2522%253A%2522EXPLORER%2522%252C%2522rootPanelGroup%2522%253A%257B%2522direction%2522%253A%2522horizontal%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522id%2522%253A%2522ROOT_LAYOUT%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522clwhwmszp00062a69kve8qr67%2522%252C%2522sizes%2522%253A%255B70%252C30%255D%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522EDITOR%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522id%2522%253A%2522clwhwmszo00022a69kmnpoevj%2522%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522SHELLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522id%2522%253A%2522clwhwmszo00042a69hys8j8t8%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522DEVTOOLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522id%2522%253A%2522clwhwmszo00052a69ir0fgsrj%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%252C%2522sizes%2522%253A%255B40%252C60%255D%257D%252C%2522tabbedPanels%2522%253A%257B%2522clwhwmszo00022a69kmnpoevj%2522%253A%257B%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clwhwmszo00012a69qvul15w8%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522FILE%2522%252C%2522filepath%2522%253A%2522%252Fpackage.json%2522%257D%255D%252C%2522id%2522%253A%2522clwhwmszo00022a69kmnpoevj%2522%252C%2522activeTabId%2522%253A%2522clwhwmszo00012a69qvul15w8%2522%257D%252C%2522clwhwmszo00052a69ir0fgsrj%2522%253A%257B%2522id%2522%253A%2522clwhwmszo00052a69ir0fgsrj%2522%252C%2522activeTabId%2522%253A%2522clwhwn9bn00762a69t1eez6ou%2522%252C%2522tabs%2522%253A%255B%257B%2522type%2522%253A%2522TASK_PORT%2522%252C%2522port%2522%253A5173%252C%2522taskId%2522%253A%2522Development%2522%252C%2522id%2522%253A%2522clwhwn9bn00762a69t1eez6ou%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522path%2522%253A%2522%252F%2522%257D%255D%257D%252C%2522clwhwmszo00042a69hys8j8t8%2522%253A%257B%2522id%2522%253A%2522clwhwmszo00042a69hys8j8t8%2522%252C%2522activeTabId%2522%253A%2522clwhwn3vd005j2a69lx70djte%2522%252C%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clwhwmszo00032a69qaxdpshw%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TERMINAL%2522%252C%2522shellId%2522%253A%2522clwhwmtee000ad9f82ygi3zda%2522%257D%252C%257B%2522type%2522%253A%2522TASK_LOG%2522%252C%2522taskId%2522%253A%2522Development%2522%252C%2522id%2522%253A%2522clwhwn3vd005j2a69lx70djte%2522%252C%2522mode%2522%253A%2522permanent%2522%257D%255D%257D%257D%252C%2522showDevtools%2522%253Atrue%252C%2522showShells%2522%253Atrue%252C%2522showSidebar%2522%253Atrue%252C%2522sidebarPanelSize%2522%253A15%257D)

I made a short gif to make the display bug clear. This only happens when I use the npm package:

![editor-gif](https://forum.bpmn.io/uploads/default/original/2X/4/444b3264b3a5be6315d94dc983d44cd2508189ae.gif)

---

<div class="post-metadata">

**Author:** ![vsgoulart](https://forum.bpmn.io/letter_avatar_proxy/v4/letter/v/977dab/32.png) [@vsgoulart](https://forum.bpmn.io/u/vsgoulart)\
**Post date:** [May 22, 2024, 3:33pm UTC](https://forum.bpmn.io/t/integrate-form-editor-in-react-js-typescript/10993/5 "2024-05-22T15:33:29Z")

</div>

@Alexander.Zeiler I believe is coming from the `useEffect` running on every render, the schema state is probably getting out of sync with the internal state from the form and that’s why the some elements disappear from the schema.

I forked your sandbox and couldn’t reproduce it anymore. You can check it [here](https://codesandbox.io/p/devbox/form-js-editor-react-forked-mspj9p?file=%2Fsrc%2FDialogEditor.tsx%3A45%2C1&layout=%257B%2522sidebarPanel%2522%253A%2522EXPLORER%2522%252C%2522rootPanelGroup%2522%253A%257B%2522direction%2522%253A%2522horizontal%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522id%2522%253A%2522ROOT_LAYOUT%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522clwhwmszp00062a69kve8qr67%2522%252C%2522sizes%2522%253A%255B70%252C30%255D%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522EDITOR%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522id%2522%253A%2522clwhwmszo00022a69kmnpoevj%2522%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522SHELLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522id%2522%253A%2522clwhwmszo00042a69hys8j8t8%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522DEVTOOLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522id%2522%253A%2522clwhwmszo00052a69ir0fgsrj%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%252C%2522sizes%2522%253A%255B55.26530339166351%252C44.73469660833649%255D%257D%252C%2522tabbedPanels%2522%253A%257B%2522clwhwmszo00022a69kmnpoevj%2522%253A%257B%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clwhwmszo00012a69qvul15w8%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522FILE%2522%252C%2522filepath%2522%253A%2522%252Fpackage.json%2522%252C%2522state%2522%253A%2522IDLE%2522%257D%252C%257B%2522id%2522%253A%2522clwhyv12t0002206abh623bqo%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522FILE%2522%252C%2522filepath%2522%253A%2522%252Fsrc%252Fstyles.css%2522%252C%2522state%2522%253A%2522IDLE%2522%257D%252C%257B%2522id%2522%253A%2522clwhyycvp002r206a8tjemhkk%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522FILE%2522%252C%2522initialSelections%2522%253A%255B%257B%2522startLineNumber%2522%253A45%252C%2522startColumn%2522%253A1%252C%2522endLineNumber%2522%253A45%252C%2522endColumn%2522%253A1%257D%255D%252C%2522filepath%2522%253A%2522%252Fsrc%252FDialogEditor.tsx%2522%252C%2522state%2522%253A%2522IDLE%2522%257D%255D%252C%2522id%2522%253A%2522clwhwmszo00022a69kmnpoevj%2522%252C%2522activeTabId%2522%253A%2522clwhyycvp002r206a8tjemhkk%2522%257D%252C%2522clwhwmszo00052a69ir0fgsrj%2522%253A%257B%2522id%2522%253A%2522clwhwmszo00052a69ir0fgsrj%2522%252C%2522activeTabId%2522%253A%2522clwhz3kk300az206abxic6m2r%2522%252C%2522tabs%2522%253A%255B%257B%2522type%2522%253A%2522TASK_PORT%2522%252C%2522port%2522%253A5173%252C%2522taskId%2522%253A%2522Development%2522%252C%2522id%2522%253A%2522clwhz3kk300az206abxic6m2r%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522path%2522%253A%2522%252F%2522%257D%255D%257D%252C%2522clwhwmszo00042a69hys8j8t8%2522%253A%257B%2522id%2522%253A%2522clwhwmszo00042a69hys8j8t8%2522%252C%2522activeTabId%2522%253A%2522clwhwn3vd005j2a69lx70djte%2522%252C%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clwhwmszo00032a69qaxdpshw%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TERMINAL%2522%252C%2522shellId%2522%253A%2522clwhwmtee000ad9f82ygi3zda%2522%257D%252C%257B%2522type%2522%253A%2522TASK_LOG%2522%252C%2522taskId%2522%253A%2522Development%2522%252C%2522id%2522%253A%2522clwhwn3vd005j2a69lx70djte%2522%252C%2522mode%2522%253A%2522permanent%2522%257D%255D%257D%257D%252C%2522showDevtools%2522%253Atrue%252C%2522showShells%2522%253Atrue%252C%2522showSidebar%2522%253Atrue%252C%2522sidebarPanelSize%2522%253A15%257D)

---

<div class="post-metadata">

**Author:** ![Alexander.Zeiler](https://forum.bpmn.io/letter_avatar_proxy/v4/letter/a/ecd19e/32.png) [@Alexander.Zeiler](https://forum.bpmn.io/u/Alexander.Zeiler)\
**Post date:** [May 23, 2024, 6:31am UTC](https://forum.bpmn.io/t/integrate-form-editor-in-react-js-typescript/10993/6 "2024-05-23T06:31:50Z")

</div>

The last useEffect is necessary to keep my value up to date from the outside. The exact same code works when I directly include the form js script in the head. As soon as I try to use the same code with the npm package, these strange display errors occur. I also tried building the package locally myself, but unfortunately, that didn’t help either.

I can still reproduce the problem in the sandbox you provided.

Do you have any other ideas on where the problem might be?

---

<div class="post-metadata">

**Author:** ![vsgoulart](https://forum.bpmn.io/letter_avatar_proxy/v4/letter/v/977dab/32.png) [@vsgoulart](https://forum.bpmn.io/u/vsgoulart)\
**Post date:** [May 23, 2024, 8:54am UTC](https://forum.bpmn.io/t/integrate-form-editor-in-react-js-typescript/10993/7 "2024-05-23T08:54:01Z")

</div>

Hi @Alexander.Zeiler

this issue requires some more investigation then. We do use the `form-js` editor with React in some of our internal apps but we don’t have this issue.

I filed [this issue](https://github.com/bpmn-io/form-js/issues/1184) in order to investigate it. We’ll take care of it on the next weeks.

---

<div class="post-metadata">

**Author:** ![barmac](https://forum.bpmn.io/user_avatar/forum.bpmn.io/barmac/32/974_2.png) [@barmac](https://forum.bpmn.io/u/barmac)\
**Post date:** [July 9, 2025, 10:10am UTC](https://forum.bpmn.io/t/integrate-form-editor-in-react-js-typescript/10993/8 "2025-07-09T10:10:45Z")

</div>

Closed on July 9, 2025, 10:10am UTC

Closing old topics.
