diff --git a/docs/addons-it-IT.html b/docs/addons-it-IT.html index 68380a8b98..44e850961d 100644 --- a/docs/addons-it-IT.html +++ b/docs/addons-it-IT.html @@ -190,6 +190,22 @@
One of the great things about React is that it doesn't require the DOM as a dependency, which means it is possible to render a React application on the server and send the HTML markup down to the client. There are a few things that React expects, so this guide will help you get started in your preferred environment.
+Nashorn is a lightweight high-performance JavaScript runtime that runs within the JVM. React should run out of the box in Java 8+.
+ +Example:
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+
+import org.apache.commons.io.IOUtils; // https://commons.apache.org/proper/commons-io/download_io.cgi
+
+public class ReactRender
+{
+ public static void main(String[] args) throws ScriptException, IOException {
+ ScriptEngine nashorn = new ScriptEngineManager().getEngineByName("nashorn");
+
+ nashorn.eval(getScript("https://fb.me/react-15.0.1.js"));
+ nashorn.eval(getScript("https://fb.me/react-dom-server-15.0.1.js"));
+
+ System.out.println(nashorn.eval("ReactDOMServer.renderToString(React.createElement('div', {}, 'Hello World!'));"));
+ }
+
+ public static String getScript(String url) throws MalformedURLException, IOException {
+ InputStream stream = new URL(url).openStream();
+ try {
+ return IOUtils.toString(stream);
+ }
+ finally {
+ stream.close();
+ }
+ }
+}
+If your application uses node modules, or you want to transform JSX in Nashorn, you will need to do some additional environment setup. The following resources may be helpful in getting you started:
+ +++Note: Using Babel within Nashorn will require Java 8u72+, as update 72 fixed JDK-8135190.
+
You can also use React within a node server-side environment.
+ +Example:
+var React = require('react');
+var ReactDOMServer = require('react-dom/server');
+
+var element = React.createElement('div', {}, 'Hello World!');
+console.log(ReactDOMServer.renderToString(element));
+++ + + +Note: Some versions of node have an
+Object.assignimplementation that does not preserve key order. This can cause errors when validating the markup, creating a warning that says "React attempted to reuse markup in a container but the checksum was invalid". If you run into this issue, you can overrideObject.assignto use a polyfill that preserves key order. For more details, see Issue #6451.
We recommend using React with a CommonJS module system like browserify or webpack. Use the react and react-dom npm packages.
// main.js
-var React = require('react');
-var ReactDOM = require('react-dom');
-
-ReactDOM.render(
- <h1>Hello, world!</h1>,
- document.getElementById('example')
-);
-To install React DOM and build your bundle with browserify:
-$ npm install --save react react-dom babelify babel-preset-react
-$ browserify -t [ babelify --presets [ react ] ] main.js -o bundle.js
-To install React DOM and build your bundle with webpack:
-$ npm install --save react react-dom babel-preset-react
-$ webpack
--- -Note:
- -If you are using ES2015, you will want to also use the
-babel-preset-es2015package.
Note: by default, React will be in development mode, which is slower, and not advised for production. To use React in production mode, set the environment variable NODE_ENV to production (using envify or webpack's DefinePlugin). For example:
new webpack.DefinePlugin({
- "process.env": {
- NODE_ENV: JSON.stringify("production")
- }
-});
-If you're not ready to use npm yet, you can download the starter kit which includes prebuilt copies of React and React DOM.
+If you're just getting started, you can download the starter kit. The starter kit includes prebuilt copies of React and React DOM for the browser, as well as a collection of usage examples to help you get started.
diff --git a/docs/top-level-api-it-IT.html b/docs/top-level-api-it-IT.html index b320ffbf58..2847ab4246 100644 --- a/docs/top-level-api-it-IT.html +++ b/docs/top-level-api-it-IT.html @@ -190,6 +190,22 @@