Skip to content

[Website] [API Reference] React, ReactDOM, ReactDOMServer Reference Guides#7931

Merged
hramos merged 3 commits intofacebook:new-docsfrom
hramos:reference
Oct 11, 2016
Merged

[Website] [API Reference] React, ReactDOM, ReactDOMServer Reference Guides#7931
hramos merged 3 commits intofacebook:new-docsfrom
hramos:reference

Conversation

@hramos
Copy link
Copy Markdown
Contributor

@hramos hramos commented Oct 10, 2016

Based on the Top-Level API Reference.

This is now split into three reference docs:

  • React
  • ReactDOM
  • ReactDOMServer

The last two used to be bundled together with the React top-level API reference, and I think the intro paragraphs for these two new documents can be expanded. Looking for feedback on what information is missing from these guides and what is no longer relevant (e.g. React.DOM is less prominent in the new reference, as is React.createElement).

React

screencapture-localhost-4000-react-docs-reference-react-html-1476138699370

ReactDOM

screencapture-localhost-4000-react-docs-reference-react-dom-html-1476138707064

ReactDOMServer

screencapture-localhost-4000-react-docs-reference-react-dom-server-html-1476138714162

Comment thread docs/docs/reference-react-dom.md Outdated
)
```

Render a ReactElement into the DOM in the supplied `container` and return a [reference](/react/docs/more-about-refs.html) to the component (or returns `null` for [stateless components](/react/docs/reusable-components.html#stateless-functions)).
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can this link to new doc instead? "Components and Props" includes a section on functional components. Also let's call them "functional components" since that's their defining trait here. Class components can also be stateless but this is not important here.

Comment thread docs/docs/reference-react-dom.md Outdated

Render a ReactElement into the DOM in the supplied `container` and return a [reference](/react/docs/more-about-refs.html) to the component (or returns `null` for [stateless components](/react/docs/reusable-components.html#stateless-functions)).

If the ReactElement was previously rendered into `container`, this will perform an update on it and only mutate the DOM as necessary to reflect the latest React component.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In the intro docs I call them just "React elements". Do we need this PascalCase notation here?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

"the latest React component" sounds a little bit confusing. The thing that gets passed is an element, not a component.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Will do. ReactElement and ReactClass are holdovers from the original reference, looks like I missed a handful on this first pass.

Comment thread docs/docs/reference-react-dom.md Outdated
> updates.
>
> `ReactDOM.render()` does not modify the container node (only modifies the children of the container). In
> the future, it may be possible to insert a component to an existing DOM node without overwriting
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we need this "in future" here? I don't think it adds value.

> the future, it may be possible to insert a component to an existing DOM node without overwriting
> the existing children.
>
> `ReactDOM.render()` currently returns a reference to the root `ReactComponent` instance. However, using this return value is legacy
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we need this ReactComponent pascal case notation here either? I would rather see us consistently use "component instance" instead. ReactComponent sounds like some sort of library-provided class which it is not.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sounds good.

Comment thread docs/docs/reference-react-dom.md Outdated
>
> `findDOMNode` only works on mounted components (that is, components that have been placed in the DOM). If you try to call this on a component that has not been mounted yet (like calling `findDOMNode()` in `render()` on a component that has yet to be created) an exception will be thrown.
>
> `findDOMNode` cannot be used on stateless components.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's use "functional" here. It works with class stateless components.

Comment thread docs/docs/reference-react.md Outdated
redirect_from: "/docs/reference.html"
---

`React` is the entry point to the React library. If you're using one of the prebuilt packages it's available as a global; if you're using CommonJS modules you can `require()` it.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Many people these days don't know what CommonJS is, and beginners who learned with Babel don't know what require() is because they only saw import.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

All feedback aside from this has been addressed. Will get back to this line tomorrow.

Comment thread docs/docs/reference-react.md Outdated
}
```

`React.Component` is the base class for React components when they are defined using ES6 classes. See the [React.Component API Reference](/react/docs/reference-react-component.html) for a list of methods are provided by the base `React.Component` class.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This makes it sound like lifecycle hooks (which is what most of that doc is dedicated to) are provided on it whereas the opposite is truth. Maybe say "related to the base ..."?

Comment thread docs/docs/reference-react.md Outdated
React.createElement(
type,
[props],
[children ...]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The notation in JS is ...children (it's part of the language). I think we should stick to that.

Comment thread docs/docs/reference-react.md Outdated
React.cloneElement(
element,
[props],
[children ...]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same

```

Return a function that produces React elements of a given type. Like [`React.createElement`](#createElement), the type argument can be either an html tag name string (eg. 'div', 'span', etc), or a `ReactClass`.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'd mention you don't need createFactory in JSX code. It mostly exists for people who don't use JSX.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Again, I think we should stop using ReactClass. This notation is misleading (e.g. "ReactClass" here could also be a function). Let's just consistently say "React component defined as a class or a function".

@gaearon
Copy link
Copy Markdown
Collaborator

gaearon commented Oct 11, 2016

Thanks! Looks great.

@hramos hramos merged commit be4e261 into facebook:new-docs Oct 11, 2016
@hramos hramos deleted the reference branch October 11, 2016 14:23
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