Browse Source

Merge pull request #1384 from chenglou/render-docs

[Docs] Rendering null/false and getDOMNode
main
Paul O’Shannessy 11 years ago
parent
commit
6f3bde9c85
  1. 2
      docs/ref-02-component-api.md
  2. 2
      docs/ref-03-component-specs.md

2
docs/ref-02-component-api.md

@ -18,7 +18,7 @@ Component classes created by `createClass()` return instances of `ReactComponent
DOMElement getDOMNode()
```
If this component has been mounted into the DOM, this returns the corresponding native browser DOM element. This method is useful for reading values out of the DOM, such as form field values and performing DOM measurements.
If this component has been mounted into the DOM, this returns the corresponding native browser DOM element. This method is useful for reading values out of the DOM, such as form field values and performing DOM measurements. When `render` returns `null` or `false`, `this.getDOMNode()` returns `null`.
### setProps

2
docs/ref-03-component-specs.md

@ -22,6 +22,8 @@ The `render()` method is required.
When called, it should examine `this.props` and `this.state` and return a single child component. This child component can be either a virtual representation of a native DOM component (such as `<div />` or `React.DOM.div()`) or another composite component that you've defined yourself.
You can also return `null` or `false` to indicate that you don't want anything rendered. Behind the scenes, React renders a `<script>` tag to work with our current diffing algorithm. When returning `null` or `false`, `this.getDOMNode()` will return `null`.
The `render()` function should be *pure*, meaning that it does not modify component state, it returns the same result each time it's invoked, and it does not read from or write to the DOM or otherwise interact with the browser (e.g., by using `setTimeout`). If you need to interact with the browser, perform your work in `componentDidMount()` or the other lifecycle methods instead. Keeping `render()` pure makes server rendering more practical and makes components easier to think about.

Loading…
Cancel
Save