Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please create better documentation on main page #39

Open
dschinkel opened this issue Apr 14, 2015 · 4 comments
Open

Please create better documentation on main page #39

dschinkel opened this issue Apr 14, 2015 · 4 comments

Comments

@dschinkel
Copy link

I know you may take it for granted and are seasoned at node + react, but on your main page can you explain the use case for this? I want to know what this gives me, not just how to use it. And being new to this, it's not that evident as you have no description and I cannot just infer by the usage why I should require jsx in my code for react. Just for newbies you need to have a little more explanation.

@alejandrosanabriav
Copy link

@dschinkel
Copy link
Author

Just asking for you to put up bit of info up front like most open source projects do... I that article explains nothing to what your module's use case.

  • Dave

On Apr 21, 2015, at 10:53 PM, Alejandro Sanabria notifications@github.com wrote:

Right here there a example how use it http://www.smashingmagazine.com/2015/04/21/react-to-the-future-with-isomorphic-apps/


Reply to this email directly or view it on GitHub.

@zpnk
Copy link

zpnk commented Apr 24, 2015

Hi @dschinkel,

With how small this module is, the usage info in the readme really is sufficient. There just isn't much more to add docs for. (The entire module is only 34 lines)

As far as why you would want/need to use this, the statement:

Transparently require() jsx from node.

kind of sums it up.

The problem this module solves is that Node cannot parse jsx files due to the syntax. If you try to require a file with jsx syntax, it will freak out. However, when working with React components on the server (such as with isomorphic apps) you will find that you do need to require jsx files, most likely to render them and send the html to the client. In order to require them without errors, you have a few options: 1) compile the jsx files to regular js first, then require that or 2) dynamically transform jsx files as they are required.

Node-jsx takes the latter, simpler approach which avoids having an extra build step on the server-side. If you already have a build process for your server, then you could just add jsx compilation there and not need to use this module. As the name implies, node-jsx is strictly for the server, and is not needed in the browser.

A quick note on usage the readme doesn't mention: The statement require('node-jsx').install() only needs to be included once, in your "entry" file. (Whatever you run to start the node process, ie: index.js, app.js, server.js, etc) I like to put it at the top, as the first line. Then it's pretty much set it and forget it.

Hope I was able to clear some things up. :)

@dschinkel
Copy link
Author

Thanks Zack, your last paragraph answered what I was missing and could not infer. I am new to node and react so I would know know of that pain yet :)

  • Dave

On Apr 24, 2015, at 11:47 AM, Zach K notifications@github.com wrote:

Hi @dschinkel,

With how small this module is, the usage info in the readme really is sufficient. There just isn't much more to add docs for. (The entire module is only 34 lines)

As far as why you would want/need to use this, the statement:

Transparently require() jsx from node.

kind of sums it up.

The problem this module solves is that Node cannot parse jsx files due to the syntax. If you try to require a file with jsx syntax, it will freak out. However, when working with React components on the server (such as with isomorphic apps) you will find that you do need to require jsx files, most likely in order to render them and send the html to the client. In order to require them without errors, you have a few options: 1) compile the jsx files to regular js first, then require that or 2) dynamically transform jsx files when they are required.

Node-jsx takes the latter, simpler approach which avoids having an extra build step on the server-side. If you already have a build process for your server, then you could just add jsx compilation and not need to use this module. As the name implies, node-jsx is strictly for the server, and is not needed in the browser.

A quick note on usage the readme doesn't mention: The statement require('node-jsx').install() only needs to be included once, in your "entry" file. (Whatever you run to start the node process, ie: index.js, app.js, server.js, etc) I like to put it at the top, as the first line. It's pretty much set it and forget it.

Hope I was able to clear some things up. :)


Reply to this email directly or view it on GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants