2

I was looking at this project https://github.com/DavidWells/isomorphic-react-example

I opened this issue https://github.com/DavidWells/isomorphic-react-example/issues/25

Do we need to still use HTML template files? ... or can we just use React components on the backend, and render like so:

res.send(ReactDOMServer.renderToString(<Comp items={items}/>));

does React allow <html> <body> and <head> tags?

If so I could just create a parent React component that can act as the template, like so:

const React = require('react');

module.exports = React.createClass({

     render: function(){

      return (

          <html lang="en">
          <head>
              <meta charset="UTF-8">
                  <title>Title</title>
          </head>
          <body>

              {this.props.body}

          </body>
          </html>

      )

   } 

});

what is the right way to do this?

Alexander Mills
  • 90,741
  • 139
  • 482
  • 817

0 Answers0