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

Cleanup environments doc #6519

Merged
merged 1 commit into from
Apr 14, 2016
Merged

Cleanup environments doc #6519

merged 1 commit into from
Apr 14, 2016

Conversation

zpao
Copy link
Member

@zpao zpao commented Apr 14, 2016

  • Use correct "Note" formatting so they render correctly
  • reordered sections so Node is first
  • Use "Node.js" consistently (it is a product name just like Nashorn)
  • added/tweaked some of the text
  • simplified the Java code so it doesn't hit the internet.

@zpao
Copy link
Member Author

zpao commented Apr 14, 2016

I haven't actually written any Java in a long time so let me know if this code is bad. Mostly I wanted to simplify the code as much as possible so I made it read react from disk instead of hitting the internet which gets rid of a few imports and half the code. I would posit that's a better practice anyway and ensures we won't miss updating some URLs later. The code also fits on the page now without horizontal scrolling.

before: https://cloudup.com/cxoRloUs8DG
after: https://cloudup.com/cMH-q9uc-Ao

System.out.println(nashorn.eval("ReactDOMServer.renderToString(React.createElement('div', {}, 'Hello World!'));"));
}
nashorn.eval(new FileReader("path/to/react.js"));
nashorn.eval(new FileReader("path/to/react-dom-server.js"));
Copy link
Contributor

@jimfb jimfb Apr 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should have a comments indicating where this file can be downloaded, because we don't put the react-dom-server.js build on the downloads page so it's not obvious where to get that file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// These files can be downloaded as a part of the starter kit from https://facebook.github.io/react

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@jimfb
Copy link
Contributor

jimfb commented Apr 14, 2016

I haven't actually written any Java in a long time so let me know if this code is bad. Mostly I wanted to simplify the code as much as possible so I made it read react from disk instead of hitting the internet which gets rid of a few imports and half the code. I would posit that's a better practice anyway and ensures we won't miss updating some URLs later. The code also fits on the page now without horizontal scrolling.

Your java changes look fine to me. Only red flag is that you don't close the FileReader (it's not obvious to me from the code if eval would close it automatically, though it probably would). Probably not a big deal / is fine as-is. Other than that, the changes look good 👍

I don't think it actually matters if we hit www verses if we hit local disk. Neither one should be on a production code path. The ScriptEngines should be pooled and re-used for requests, so you'd never hit disk/web for an incoming request anyway.

@zpao
Copy link
Member Author

zpao commented Apr 14, 2016

you don't close the FileReader

I copied that right from https://docs.oracle.com/javase/8/docs/technotes/guides/scripting/prog_guide/api.html :) It might not be perfectly right but figured good enough if they're using that pattern.

- Use correct "Note" formatting so they render correctly
- reordered sections so Node is first
- Use "Node.js" consistently (it is a product name just like Nashorn)
- added/tweaked some of the text
- simplified the Java code so it doesn't hit the internet.
@gaearon
Copy link
Collaborator

gaearon commented Apr 14, 2016

👍 I’ll keep these in mind for the next time!

zpao added a commit that referenced this pull request Apr 22, 2016
Cleanup environments doc
(cherry picked from commit befb70e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants