Polotno has rich store API
that you can use to observe and control canvas content. store
object is created using mobx
library. You can use mobx js methods to create react components.
Observable component
To create a component that is automatically updated, when canvas is changed you need to use observer
api from mobx-react-lite
library:
Store reaction
store
object has a "change" event to listen to when some content on canvas is changed. The event triggered only when canvas content is changed. If you select or deselect elements, it will NOT trigger "change" event.
In some cases, you may want to react to selection or some other data change in the store. In the case you can use reaction
or autorun
methods from mobx
library: