1.react.rendertostring function, parameter is component, returns a string
<! DOCTYPE html>. Example-enter{color:red;} . Example-Active{color:green;} </style> varMyComponent =React.createclass ({render:function(){ return ( <div>hello world!</div> ); } }); varWorld = react.rendertostring (<mycomponent/>);alert (world); Console.log (World); </script> </body>2. Another server-side render function: React.rendertostaticmarkup, he does not have the Data property
<! DOCTYPE html>. Example-enter{color:red;} . Example-Active{color:green;} </style> varMyComponent =React.createclass ({render:function(){ return ( <div>hello world!</div> ); } }); //var world = react.rendertostring (<mycomponent/>); varWorld = React.rendertostaticmarkup (<mycomponent/>);alert (world); Console.log (World); </script> </body>When are they used?
You should choose to use the React.rendertostaticmarkup function when and only if you are not going to render the react component on the client, such as:
- Generate HTML e-mail
- Generate PDFs from HTML to PDF conversions
- Component testing
In most cases, we use react.rendertostring () to render the service side.
React (0.13) two functions rendered by a server