Rendering a component more than once can result in unintended consequences. For example, if your component uses DeferredRender to capture slots, the content of those slots will leak between different renders of the same instance.
I think we should update Phlex to disallow this, raising an error if you attempt to render the same instance of a component more than once. The place to do this would be in __final_call__ which is the method that gets renamed to call after the first render for caching.
Rendering a component more than once can result in unintended consequences. For example, if your component uses
DeferredRender
to capture slots, the content of those slots will leak between different renders of the same instance.I think we should update Phlex to disallow this, raising an error if you attempt to render the same instance of a component more than once. The place to do this would be in
__final_call__
which is the method that gets renamed tocall
after the first render for caching.https://github.com/phlex-ruby/phlex/blob/6a0eb85d2fe6e3959644c45185150ee29856eee0/lib/phlex/sgml.rb#L97-L127
I would approach this by first checking for an instance variable and raising if it's true, and then setting that instance variable to true.