Skip to content

Commit

Permalink
Merge pull request facebook#618 from chenglou/didmout-didUpdate-new
Browse files Browse the repository at this point in the history
docs remove rootNode for componentDidMount/Update
  • Loading branch information
zpao committed Nov 28, 2013
2 parents 98b9e2f + cffb115 commit d8a1dbb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
10 changes: 2 additions & 8 deletions docs/docs/07-working-with-the-browser.md
Expand Up @@ -80,15 +80,15 @@ React provides lifecycle methods that you can specify to hook into this process.

* `getInitialState(): object` is invoked before a component is mounted. Stateful components should implement this and return the initial state data.
* `componentWillMount()` is invoked immediately before mounting occurs.
* `componentDidMount(DOMElement rootNode)` is invoked immediately after mounting occurs. Initialization that requires DOM nodes should go here.
* `componentDidMount()` is invoked immediately after mounting occurs. Initialization that requires DOM nodes should go here.


### Updating

* `componentWillReceiveProps(object nextProps)` is invoked when a mounted component receives new props. This method should be used to compare `this.props` and `nextProps` to perform state transitions using `this.setState()`.
* `shouldComponentUpdate(object nextProps, object nextState): boolean` is invoked when a component decides whether any changes warrant an update to the DOM. Implement this as an optimization to compare `this.props` with `nextProps` and `this.state` with `nextState` and return false if React should skip updating.
* `componentWillUpdate(object nextProps, object nextState)` is invoked immediately before updating occurs. You cannot call `this.setState()` here.
* `componentDidUpdate(object prevProps, object prevState, DOMElement rootNode)` is invoked immediately after updating occurs.
* `componentDidUpdate(object prevProps, object prevState)` is invoked immediately after updating occurs.


### Unmounting
Expand All @@ -103,12 +103,6 @@ _Mounted_ composite components also support the following methods:
* `getDOMNode(): DOMElement` can be invoked on any mounted component in order to obtain a reference to its rendered DOM node.
* `forceUpdate()` can be invoked on any mounted component when you know that some deeper aspect of the component's state has changed without using `this.setState()`.

> Note:
>
> The `DOMElement rootNode` argument of `componentDidMount()` and
> `componentDidUpdate()` is a convenience. The same node can be obtained by
> calling `this.getDOMNode()`.

## Browser Support and Polyfills

Expand Down
14 changes: 11 additions & 3 deletions docs/docs/ref-03-component-specs.md
Expand Up @@ -84,13 +84,17 @@ Invoked immediately before rendering occurs. If you call `setState` within this
### Mounting: componentDidMount

```javascript
componentDidMount(DOMElement rootNode)
componentDidMount()
```

Invoked immediately after rendering occurs. At this point in the lifecycle, the component has a DOM representation which you can access via the `rootNode` argument or by calling `this.getDOMNode()`.
Invoked immediately after rendering occurs. At this point in the lifecycle, the component has a DOM representation which you can access via `this.getDOMNode()`.

If you want to integrate with other JavaScript frameworks, set timers using `setTimeout` or `setInterval`, or send AJAX requests, perform those operations in this method.

> Note:
>
> Prior to v0.6, the DOM node was passed in as the last argument. If you were using this, you can still access the DOM node by calling `this.getDOMNode()`.

### Updating: componentWillReceiveProps

Expand Down Expand Up @@ -157,13 +161,17 @@ Use this as an opportunity to perform preparation before an update occurs.
### Updating: componentDidUpdate

```javascript
componentDidUpdate(object prevProps, object prevState, DOMElement rootNode)
componentDidUpdate(object prevProps, object prevState)
```

Invoked immediately after updating occurs. This method is not called for the initial render.

Use this as an opportunity to operate on the DOM when the component has been updated.

> Note:
>
> Prior to v0.6, the DOM node was passed in as the last argument. If you were using this, you can still access the DOM node by calling `this.getDOMNode()`.

### Unmounting: componentWillUnmount

Expand Down

0 comments on commit d8a1dbb

Please sign in to comment.