facebookarchive / react-page

Easy Application Development with React JavaScript
Apache License 2.0
797 stars 72 forks source link

Clarify how to share a component between server and client #54

Open adelevie opened 10 years ago

adelevie commented 10 years ago

I got to hello world with this:

/**
 *
 * @jsx React.DOM
 */

var React = require('React');
var SiteBoilerPlate = require('../core/SiteBoilerPlate.js');
var Banner = require('../elements/Banner/Banner.js');

var hello = React.createClass({

  render: function() {
    return (
      <SiteBoilerPlate>
        <h1>HELLLLOO!!!!!111</h1>
      </SiteBoilerPlate>
    );
  }
});

module.exports = hello;

I'm wondering how I access this component from the client. I'm assuming that as it stands now, if I fire up node server.js and visit localhost:8080/pages/hello.html, that this is all rendered on the server. How would I render this from the client?

Perhaps the answer is obvious, but it's not obvious to me, and maybe many others.