-
Notifications
You must be signed in to change notification settings - Fork 50.2k
Installation instructions #7858
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
Conversation
| <div class="buttons-unit"> | ||
| <a href="/react/docs/getting-started.html" class="button">Get Started</a> | ||
| <a href="/react/downloads.html" class="button">Download React v{{site.react_version}}</a> | ||
| <a href="/react/docs/tutorial.html" class="button">Take the Tutorial</a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a nit from a non-native speaker, but this:
Reminds me of this.
I honestly wouldn’t know which to choose. If I’m new to React, should I “Get Started” or “Take the Tutorial”? Does taking a tutorial presume I already “got started”? Does “getting started” presume I already know things in the tutorial?
docs/docs/getting-started.md
Outdated
| --- | ||
|
|
||
| ## JSFiddle | ||
| There are several different ways to use React. The right one for you depends on how you're using it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think people get a little frustrated when we say there are multiple ways to do the same thing. Maybe approach it from a different angle? e.g.
React is flexible and accommodates a variety of projects. You can create new apps with it, but you can also gradually introduce it into an existing codebase without doing a rewrite.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok i took most of your wording here
docs/docs/getting-started.md
Outdated
| * **[React JSFiddle](https://jsfiddle.net/reactjs/69z2wepo/)** | ||
| * [React JSFiddle without JSX](https://jsfiddle.net/reactjs/5vjqabv3/) | ||
| If you're just interested in playing around with React, you can use JSFiddle. Try starting from [this Hello World example code](https://jsfiddle.net/o9gspf3e/). You don't need to install anything; you can just modify the code and click "Run" to see if it works. | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this section should offer to download an index.html file that lets you play with React. That file would use react@latest and react-dom@latest from unpkg so we wouldn’t need to update it. I don’t think there is a need to write out this file's contents on the page though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
docs/docs/getting-started.md
Outdated
| ## Creating a New Application | ||
|
|
||
| **[Create React App](http://github.com/facebookincubator/create-react-app)** is a new officially supported way to create single-page React applications. It offers a modern build setup with no configuration. It requires Node 4 or higher. | ||
| [`create-react-app`](http://github.com/facebookincubator/create-react-app) is the best way to starting building a new React single page application. It handles webpack, babel, and live reloading, so you don't have to think about them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I style it as Create React App everywhere, can we keep that instead of the CLI name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's weird man but ok
docs/docs/getting-started.md
Outdated
| If you're just interested in playing around with React, you can use JSFiddle. Try starting from [this Hello World example code](https://jsfiddle.net/o9gspf3e/). You don't need to install anything; you can just modify the code and click "Run" to see if it works. | ||
|
|
||
| ## Create React App | ||
| ## Creating a New Application |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say Creating a Single Page Application because this is the specific use case CRA handles. For anything else, you should just use the bundler and do things your way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll change this wording. What is actually the best way to build e.g. a Rails + React non-single-page app? It seems like it might actually be to start with Create React App. But I dunno for sure so I'll hold off on that for now. "Building a new non-single-page-app" seems like it's one of the key omissions here at the moment, but I don't know what to recommend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Let's add this as a separate section. It should tell people to:
- Either use React from npm or CDN
- Add Babel to their asset pipeline (there are many ways) and then ensure they enable
'es2015', 'react'as presets
That Babel link is really exhaustive and includes Rails.
docs/docs/getting-started.md
Outdated
| npm start | ||
| ``` | ||
|
|
||
| `create-react-app` doesn't handle backend logic or databases; it just creates a frontend build pipeline, so you can use it with any backend you want. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked around but it wasn't clear to me what were good Node / Rails tutorials that adhered to best practices. Do you have particular suggestions that you like or have heard good things about? If not, maybe we should just let people Google around themselves.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I linked to the particular ones in the comment 😄
I think these are pretty good as CRA+Node and CRA+Rails intros, not as React intros though.
docs/docs/getting-started.md
Outdated
| ```js | ||
| var React = require('react'); | ||
| var ReactDOM = require('react-dom'); | ||
| ReactDOM.render(<App />, document.getElementById('the-element-id')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's write the "hello world" App component here inline as a class?
Also let's change document.getElementById('the-element-id') to document.getElementById('root') and mention that you need:
<div id="root"></div>in your HTML file- Babel with
reactandes2015presets
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
docs/docs/getting-started.md
Outdated
| ## Adding React to an Existing Application | ||
|
|
||
| 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. | ||
| We recommend using React from npm with a bundler like [browserify](http://browserify.org/) or [webpack](https://webpack.github.io/). If you already have npm in your build pipeline, you can install it with: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: npm is not a part of the build pipeline.
Maybe "if you use npm for package management"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK fixed
docs/docs/getting-started.md
Outdated
| ReactDOM.render(<App />, document.getElementById('the-element-id')); | ||
| ``` | ||
|
|
||
| If you use Bower, React is available via the `react` package: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bower should come after a section about UMDs. Right here we should mention that react and react-dom npm packages provide UMD distributions in dist folders, and that we also host the same files on CDN.
docs/docs/getting-started.md
Outdated
|
|
||
| ## Using React From A CDN | ||
|
|
||
| If you don't have any build pipeline set up, you can still use React directly from a CDN. You also need to load `babel` from a CDN and load your scripts with type `text/babel` so that they can get transformed. This code works as a single html file: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would completely remove this section. It conflates two different things:
- Using React from CDN (fine for dev and prod)
- Using in-browser Babel transform (exists only for trying React and literally nothing else)
This section gives a wrong impression that somehow using React from CDN is bad, which it is not.
I think, as I mentioned above, the section on React CDN files should be merged with Adding React to an Existing Application, and the part about in-browser Babel can be fully omitted and instead added to a downloadable index.html in Trying Out React.
docs/docs/getting-started.md
Outdated
| ``` | ||
|
|
||
| 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. | ||
| Create React App doesn't handle backend logic or databases; it just creates a frontend build pipeline, so you can use it with any backend you want. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add here: "It uses Webpack, Babel and ESLint under the hood, but configures them for you."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
| </a> | ||
| </div> | ||
| ## Adding React to an Existing Application | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a section called "Enabling ES6 and JSX" that tells people to use Babel and points to https://babeljs.io/docs/setup/. We can then say something like "make sure you install babel-preset-react and babel-preset-es2015 and enable them in .babelrc, and you're good to go"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
| <title>Hello React World!</title> | ||
| <script src="https://unpkg.com/react@latest/dist/react.js"></script> | ||
| <script src="https://unpkg.com/react-dom@latest/dist/react-dom.js"></script> | ||
| <script src="https://unpkg.com/[email protected]/browser.min.js"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use https://unpkg.com/[email protected]/babel.min.js here instead.
Like in #7669.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok



This PR combines the information from the "downloads" tab and the "getting started" page into one document.
The home page used to have two calls to action - "downloads" and "getting started". I don't think we need both of those, because they are kinda similar; I think we should make one of them "take the tutorial" instead. For now that points to the old tutorial but we can update it once the new one is in.
There are probably useful details I'm still missing here, so I'd appreciate feedback. I wish there was better advice for people who don't want a single-page app, but also don't already have a build pipeline set up.
Also I updated the fiddle to use ES6 classes so feel free to look at that too