I don't get the updated diagram when saving (React Hooks)

Hello everyone,

I have a problem, when I click the save button, the updated diagram is not saved.

  const [diagram, setDiagram] = useState(emptyBpmn);

try {
      await modeler.importXML(diagram);
      const { xml } = await modeler.saveXML();
      const canvas = modeler.get("canvas");
    } catch (err) {

Code in sandbox

This is because each time you click the save button, a new instance of Modeler is created which imports the initial diagram. I re-arranged and simplified your codesandbox so that it imports BPMN only once and then only displayed saved XML:

1 Like

Thank you very much, the code is very complete!