If you want to convert react JSX object to HTML? Here is the full code that I had to use in my react/redux application.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | import React from 'react'; import ReactDOMServer from 'react-dom/server'; import {Provider} from 'react-redux'; ... class ParentComponent extends React.Component { ... getHtml(config) { const {classes, children} = config return ReactDOMServer.renderToStaticMarkup( <Provider store={this.context.store}> <ChildComponent classes={classes}>{children}</ChildComponent> </Provider> ) } } ParentComponent.contextTypes = { store: React.PropTypes.object }; |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.