Skip to content

Conversation

@lacker
Copy link
Contributor

@lacker lacker commented Oct 4, 2016

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

@lacker
Copy link
Contributor Author

lacker commented Oct 4, 2016

screencapture-localhost-4000-react-docs-getting-started-html-1475540337046

<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>
Copy link
Collaborator

@gaearon gaearon Oct 4, 2016

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:

screen shot 2016-10-04 at 13 34 00

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?

---

## JSFiddle
There are several different ways to use React. The right one for you depends on how you're using it.
Copy link
Collaborator

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.

Copy link
Contributor Author

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

* **[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.

Copy link
Collaborator

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK

## 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.
Copy link
Collaborator

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?

Copy link
Contributor Author

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

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
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

Copy link
Collaborator

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:

  1. Either use React from npm or CDN
  2. 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.

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.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe link to Node and Rails tutorials?

Copy link
Contributor Author

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.

Copy link
Collaborator

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.

```js
var React = require('react');
var ReactDOM = require('react-dom');
ReactDOM.render(<App />, document.getElementById('the-element-id'));
Copy link
Collaborator

@gaearon gaearon Oct 4, 2016

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 react and es2015 presets

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK

## 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:
Copy link
Collaborator

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"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK fixed

ReactDOM.render(<App />, document.getElementById('the-element-id'));
```

If you use Bower, React is available via the `react` package:
Copy link
Collaborator

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.


## 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:
Copy link
Collaborator

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.

@lacker
Copy link
Contributor Author

lacker commented Oct 4, 2016

screencapture-localhost-4000-react-docs-getting-started-html-1475598843860

OK I fixed everything except the call-to-action buttons on the homepage, because it's not clear to me what the right thing is to do. The ideal pages to point to probably don't even exist yet so maybe we can just change it later.

```

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.
Copy link
Collaborator

@gaearon gaearon Oct 4, 2016

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."

Copy link
Contributor Author

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

Copy link
Collaborator

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"

Copy link
Contributor Author

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>
Copy link
Collaborator

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

@lacker lacker merged commit cb862e1 into facebook:new-docs Oct 4, 2016
@lacker lacker deleted the installation branch October 4, 2016 17:52
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.

3 participants