nocode-js / sequential-workflow-editor

Powerful workflow editor builder for any workflow designer.
https://nocode-js.com/
MIT License
87 stars 8 forks source link

In react app, how to get the value of global editor? #25

Closed nguyenngoclongdev closed 1 year ago

nguyenngoclongdev commented 1 year ago

In react app, how to get the value of global editor? I try to use hook useGlobalEditor, but throw exception.

react_devtools_backend_compact.js:12966 React Router caught the following error during render Error: Cannot find global editor context
    at useGlobalEditor (index.js:75:11)
    at WorkflowEditor (WorkflowEditor.tsx:54:106)
    at fm (react-dom.development.js:1:152112)
    at react-dom.development.js:1:196268
    at Hg (react-dom.development.js:1:197617)
    at qw (react-dom.development.js:1:244731)
    at Lw (react-dom.development.js:1:237660)
    at _w (react-dom.development.js:1:237542)
    at Nw (react-dom.development.js:1:237304)
    at mw (react-dom.development.js:1:234875) 
b4rtaz commented 1 year ago

Hello @nguyenngoclongdev! You can use useGlobalEditor only inside the editor. To read a value from the editor outside you should read your definition.

nguyenngoclongdev commented 1 year ago

@b4rtaz Thank you for the quick answer. However, I am using the sequential-workflow-designer + sequential-workflow-editor, and I am unable to read the value of the global editor with useGlobalEditor hook.

b4rtaz commented 1 year ago

You cannot use the useGlobalEditor() hook with the sequential workflow editor, because it doesn't use React hooks.

To read values provided by the root editor you should read the root properties of your definition (Definition { properties: ... }).

nguyenngoclongdev commented 1 year ago

@b4rtaz thank you for your answear.