Skip to content

Commit 575bdb2

Browse files
committed
Merge pull request #6 from paulshen/apidocs
[docs] Clean up formatting on /api.html
2 parents ece5b92 + b416760 commit 575bdb2

File tree

1 file changed

+69
-23
lines changed

1 file changed

+69
-23
lines changed

docs/docs/api.md

Lines changed: 69 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,23 @@ prev: advanced-components.html
99

1010
`React` is the entry point to the React framework. 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.
1111

12-
### DOM
12+
#### React.DOM
1313

1414
`React.DOM` provides all of the standard HTML tags needed to build a React app. You generally don't use it directly; instead, just include it as part of the `/** @jsx React.DOM */` docblock.
1515

16-
### initializeTouchEvents(boolean shouldUseTouch)
16+
#### React.initializeTouchEvents
17+
18+
```javascript
19+
initializeTouchEvents(boolean shouldUseTouch)
20+
```
1721

1822
Configure React's event system to handle touch events on mobile devices.
1923

20-
### function autoBind(function method)
24+
#### React.autoBind
25+
26+
```javascript
27+
function autoBind(function method)
28+
```
2129

2230
Marks the provided function to be automatically bound to each React component instance created. This allows React components to define automatically bound methods and ensure that when called they will always reference their current instance.
2331

@@ -35,11 +43,19 @@ React.createClass({
3543
});
3644
```
3745

38-
### function createClass(object specification)
46+
#### React.createClass
47+
48+
```javascript
49+
function createClass(object specification)
50+
```
3951

4052
Creates a component given a specification. A component implements a `render` method which returns a single child. That child may have an arbitrarily deep child structure. One thing that makes components different than a standard prototypal classes is that you don't need to call new on them. They are convenience wrappers that construct backing instances (via new) for you.
4153

42-
### ReactComponent renderComponent(ReactComponent container, DOMElement mountPoint)
54+
#### React.renderComponent
55+
56+
```javascript
57+
ReactComponent renderComponent(ReactComponent container, DOMElement mountPoint)
58+
```
4359

4460
Renders a React component into the DOM in the supplied `container`.
4561

@@ -55,50 +71,80 @@ If you find that you need the underlying browser event for some reason, simply u
5571

5672
Component classses created by `createClass()` return instances of `ReactComponent` when called. Most of the time when you're using React you're either creating or consuming `ReactComponent`s.
5773

58-
### DOMElement getDOMNode()
74+
#### getDOMNode
75+
76+
```javascript
77+
DOMElement getDOMNode()
78+
```
5979

6080
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.
6181

62-
### setProps(object nextProps)
82+
#### setProps
83+
84+
```javascript
85+
setProps(object nextProps)
86+
```
6387

6488
When you're integrating with an external JavaScript application you may want to signal a change to a React component rendered with `renderComponent()`. Simply call `setProps()` to change its properties and trigger a re-render.
6589

6690
**Note:** This method can only be called on a root-level component. That is, it's only available on the component passed directly to `renderComponent()` and none of its children. If you're inclined to use `setProps()` on a child component, instead take advantage of reactive updates and pass the new prop to the child component when it's created in `render()`.
6791

68-
### replaceProps(object nextProps)
92+
#### replaceProps
93+
94+
```javascript
95+
replaceProps(object nextProps)
96+
```
6997

7098
Like `setProps()` but deletes any pre-existing props that are not in nextProps.
7199

72-
### ReactComponent transferPropsTo(ReactComponent targetComponent)
100+
#### transferPropsTo
101+
102+
```javascript
103+
ReactComponent transferPropsTo(ReactComponent targetComponent)
104+
```
73105

74106
Transfer properties from this component to a target component that have not already been set on the target component. This is usually used to pass down properties to the returned root component. `targetComponent`, now updated with some new props is returned as a convenience.
75107

76-
### setState(object nextState)
108+
#### setState
109+
110+
```javascript
111+
setState(object nextState)
112+
```
77113

78114
Merges nextState with the current state. This is the primary method you use to trigger UI updates from event handlers and server request callbacks.
79115

80116
**Note:** *NEVER* mutate `this.state` directly. As calling `setState()` afterwards may replace the mutation you made. Treat `this.state` as if it were immutable.
81117

82118
**Note:** `setState()` does not immediately mutate `this.state` but creates a pending state transition. Accessing `this.state` after calling this method can potentially return the existing value.
83119

84-
### replaceState(object nextState)
120+
#### replaceState
121+
122+
```javascript
123+
replaceState(object nextState)
124+
```
85125

86126
Like `setState()` but deletes any pre-existing state keys that are not in nextState.
87127

88-
### forceUpdate()
128+
#### forceUpdate()
129+
130+
```javascript
131+
forceUpdate()
132+
```
89133

90134
If your `render()` method reads from something other than `this.props` or `this.state` you'll need to tell React when it needs to re-run `render()`. Use `forceUpdate()` to cause React to automatically re-render. This will cause `render()` to be called on the component and all of its children but React will only update the DOM if the markup changes.
91135

92136
Normally you should try to avoid all uses of `forceUpdate()` and only read from `this.props` and `this.state` in `render()`. This makes your application much simpler and more efficient.
93137

94-
### object getInitialState()
95-
### componentWillMount()
96-
### componentDidMount(DOMElement domNode)
97-
### componentWillReceiveProps(object nextProps)
98-
### boolean shouldComponentUpdate(object nextProps, object nextState)
99-
### componentWillUpdate(object nextProps, object nextState)
100-
### ReactComponent render()
101-
### componentDidUpdate(object prevProps, object prevState, DOMElement domNode)
102-
### componentWillUnmount()
103-
104-
These are overridable lifecycle methods; see the [lifecycle methods](lifecycle.html) documentation for more information.
138+
```javascript
139+
object getInitialState()
140+
componentWillMount()
141+
componentDidMount(DOMElement domNode)
142+
componentWillReceiveProps(object nextProps)
143+
boolean shouldComponentUpdate(object nextProps, object nextState)
144+
componentWillUpdate(object nextProps, object nextState)
145+
ReactComponent render()
146+
componentDidUpdate(object prevProps, object prevState, DOMElement domNode)
147+
componentWillUnmount()
148+
```
149+
150+
See the [advanced components](advanced-components.html) documentation for more details on these lifecycle methods.

0 commit comments

Comments
 (0)