spotfiresoftware / spotfire-mods

Spotfire® Mods
https://spotfiresoftware.github.io/spotfire-mods/
Other
54 stars 41 forks source link

How to manage Mount and Unmount of a component? #85

Closed heberleh closed 2 years ago

heberleh commented 2 years ago

While resizing a component with a visualization in Spotfire I got this message from React:

Warning: render(...): It looks like the React-rendered content of this container was removed without using React. This is not supported and will cause errors. Instead, call ReactDOM.unmountComponentAtNode to empty a container.

Is there a callback where I can plug an unmount action?

I'm using TIBCO® Spotfire® 11.4.1 LTS

heberleh commented 2 years ago

The method context.signalRenderComplete() must be called ONLY after our App/Vis React component is mounted. If this condition is met, we don't need to track unmountComponent.

objerke commented 2 years ago

Hi @heberleh, I'm unsure what your issue is. The Mods API is UI framework/library agnostic and does not modify the DOM itself. My guess is that you are clearing the DOM or creating a react render root in your subscribe callback? I might be able to help given some code showing the issue.

The context.signalRenderComplete() method needs to be called at a time when you are certain the mod has finished rendering to the DOM. It is used by the Mods API to let Spotfire's export engine know when a mod is ready to be exported. Maybe React's componentDidMount() functionality is a good place to call the method.