DavidWells / isomorphic-react-example

Deprecated! ReactJS + NodeJS ( express ) demo tutorial with video. Universal/Isomorphic JS = Shared JavaScript that runs on both the client & server.
http://davidwells.io
MIT License
1.69k stars 272 forks source link

Why not do away with .ejs templates altogether #25

Open ORESoftware opened 8 years ago

ORESoftware commented 8 years ago

I used to think that having templates (like .ejs) was needed or useful with React. But now I believe you can just do away with it entirely, and use React's compose-ability.

So why no create a parent component that looks something 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>

      )
   } 
});

perhaps React does not allow <html> <body> <head> tags?

ORESoftware commented 8 years ago

I asked a question on SO about this:

http://stackoverflow.com/questions/36320430/server-side-rendering-with-react-confused-about-whether-we-still-need-template?noredirect=1#comment60264463_36320430

seems like you don't need .html templates anymore?