I’m using React in my UI panel. Contemporary React uses hooks. The concept of the useEffect
hook is that,
- actions like button clicks should set state
- the
useEffect
should process ‘side effects’ that you want to happen when it observes state changes.
In my case, I have a UI panel with buttons that allow me to modify the appearance of nodes in my document. Ex. if I click a button that should increase the font size, I click it, increment the state variable fontSize
in my react component. Then, useState
has fontSize
as a dependency which triggers its function to run. Its function calls XD’s editDocument
which then has a routine to apply the new text styles to the selection. When I do this though XD gives me an error, “[Error: Panel plugin edits must be initiated from a supported UI event]” (not directly because of this asynchronous paradigm that react has). I guess there’s no way around that?