So my question is this: In React, there is a way to do this:
var renderedComponent = React.render(<MyComponent />, document.body);
...and React with render the element MyComponent
to a component, and mount it at document.body
.
If I don't want to mount my component on the real DOM, then I do:
var renderedString = React.renderToString(<MyComponent />);
However, if I want to render the element to a component, and not mount it to any real DOM node, I can't seem to figure out how to do this. Basically I want to do:
var renderedComponent = React.renderToVirtual(<MyComponent />)
// do some stuff with the component
renderedComponent.doSomeStuff(...)
// now we're done, render it to a string
var renderedString = React.componentToString(renderedComponent)
So basically the two methods I can't seem to find are: 1) renderToVirtual
, and componentToString
. Any pointers on how to achieve this? Thanks!