[Embeddable] Seamless React integration #140395
Labels
Feature:Embedding
Embedding content via iFrame
impact:high
Addressing this issue will have a high level of impact on the quality/strength of our product.
loe:large
Large Level of Effort
Team:Presentation
Presentation Team for Dashboard, Input Controls, and Canvas
Background
The current way of rendering React applications inside an embeddable widget requires the usage of the
react-dom
library. Because of that, we have a detached Virtual DOM tree per each widget, which may negatively impact performance.Another downside of this approach is that we are losing the React context, and we have to reinitialize in every implementation (e.g., internationalization and theme). That causes code repetition along with growing technical debt.
Proposal
We can provide seamless integration with React by extending our contract to allow returning React elements in the
render
function. We can conditionally mount returned React children in the runtime or fall back to the existing approach.Additionally, we can allow third-party applications to return regular DOM nodes that will be appended to the containing node. This change should abstract us from DOM manipulation inside embeddable components.
These changes should provide better interaction with React as well as a framework-agnostic way of rendering widgets. This can be done by using methods polymorphism in TypeScript and providing multiple
render
method overloads. In the base implementation, we can check the method’s returned value and mount that into the existing Virtual DOM tree.The text was updated successfully, but these errors were encountered: