Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A way to return raw HTML from an unmounted component? #7374

Closed
BlockChange opened this issue Jul 29, 2016 · 1 comment
Closed

A way to return raw HTML from an unmounted component? #7374

BlockChange opened this issue Jul 29, 2016 · 1 comment

Comments

@BlockChange
Copy link

I've asked the same question here but it seems that the only way is to use ReactDOMServer.renderToStaticMarkup(component) which must be a mounted component first, and I'd just like to feed raw HTML to a plugin like the above linked question.

I also like to avoid jQuery with this, and just have a way to mount a component in the shadow, and then have the raw HTML ( not sure how it's called, when you console.log a html element, in chrome it outputs the html as a sort of native html object )

The only other way I can imagine is using a ref to an element, but that still has to be mounted.

@apapirovski
Copy link

apapirovski commented Aug 5, 2016

Server-side components are never mounted (and componentDidMount doesn't fire on the server). ReactDOMServer.renderToStaticMarkup will literally just generate HTML markup to use.

See this fiddle: https://jsfiddle.net/onq7ooyj/1/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants