How to replace one Component with another?

Hi everyone! I’m trying to write Vaadin with functional (react-like) style, where I have a function that takes some state and returns Component. The problem is that for now I’m replacing existing Components with the new ones, which results in discarding of all their state (the most prominent ones are focus loss and various animation/expansion effects reset). Do you know if there is a way to transfer the state of one component to the other one so that the internal state is not reset. I’m thinking this may be on the Elements level rather than Component, which also works for me. Anything is better than manually overriding all the attributes for each Component in the tree.

Up.

Component#setElement is private, but you could use reflection to call it. Theoretically, you could serialize/deserialize an Element and assign any element to a component. Though, I imagine this would mess with the state tree

I hope that is a good starting place.

Vaadin is not meant to be used this way.