I'm wondering if this is possible and if anyone did something similar before.
I need a way to serialize react component definitions (essentially react classes, or functions...) on the server side and somehow pass them to the client side.
The problem I'm hitting is due to the fact that I'm rendering a set of subcomponents dynamically, based on a dynamic list. Upon a request, I consult a service for a list of URLs, require all the js assets from the list (they happen to be components packaged with umd) and I am able to render the server side content dynamically.
The problem happens on the client side when I hydrate the content. All the components re-render but the previously fetched component disappear from the DOM because the component state is empty (the components available on the server side, although rendered, are not available on the client side). I could of course before the hydration, fetch the list and the components again (similar to the logic on the server side). That, of course, would defeat the purpose of server side rendering these components entirely, so I'm wondering if there is a better way to do what I want. There MUST be a way to send the already available react component definitions from the server side to the client side and save a hop.
Any thoughts? Any help is appreciated