[Website] [API Reference] React, ReactDOM, ReactDOMServer Reference Guides#7931
[Website] [API Reference] React, ReactDOM, ReactDOMServer Reference Guides#7931hramos merged 3 commits intofacebook:new-docsfrom
Conversation
| ) | ||
| ``` | ||
|
|
||
| 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)). |
There was a problem hiding this comment.
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.
|
|
||
| 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. |
There was a problem hiding this comment.
In the intro docs I call them just "React elements". Do we need this PascalCase notation here?
There was a problem hiding this comment.
"the latest React component" sounds a little bit confusing. The thing that gets passed is an element, not a component.
There was a problem hiding this comment.
Will do. ReactElement and ReactClass are holdovers from the original reference, looks like I missed a handful on this first pass.
| > 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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
| > | ||
| > `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. |
There was a problem hiding this comment.
Let's use "functional" here. It works with class stateless components.
| 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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
All feedback aside from this has been addressed. Will get back to this line tomorrow.
| } | ||
| ``` | ||
|
|
||
| `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. |
There was a problem hiding this comment.
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 ..."?
| React.createElement( | ||
| type, | ||
| [props], | ||
| [children ...] |
There was a problem hiding this comment.
The notation in JS is ...children (it's part of the language). I think we should stick to that.
| React.cloneElement( | ||
| element, | ||
| [props], | ||
| [children ...] |
| ``` | ||
|
|
||
| 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`. | ||
|
|
There was a problem hiding this comment.
I'd mention you don't need createFactory in JSX code. It mostly exists for people who don't use JSX.
There was a problem hiding this comment.
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".
|
Thanks! Looks great. |
Based on the Top-Level API Reference.
This is now split into three reference docs:
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
ReactDOM
ReactDOMServer