Add links to docs for addons and top level API (#6555)
This makes it easier to figure out where the docs live. Googling for e.g. `react-addons-update` also works, but this should make things easier for people that hyperclick directly to the source.
Desmond Brand committed
May 2, 2016 at 06:14 UTC
db175052c00a65e6a852011f889c12fea50bb34b
17 files changed
+76
-7
src/addons/ReactComponentWithPureRenderMixin.js
+2
@@ -36,6 +36,8 @@ var shallowCompare = require('shallowCompare');
36
* complex data structures this mixin may have false-negatives for deeper
37
* differences. Only mixin to components which have simple props and state, or
38
* use `forceUpdate()` when you know deep data structures have changed.
39
+ *
40
+ * See https://facebook.github.io/react/docs/pure-render-mixin.html
41
*/
42
var ReactComponentWithPureRenderMixin = {
43
shouldComponentUpdate: function(nextProps, nextState) {
src/addons/ReactFragment.js
+5
-2
@@ -31,8 +31,11 @@ var numericPropertyRegex = /^\d+$/;
31
var warnedAboutNumeric = false;
32
33
var ReactFragment = {
34
- // Wrap a keyed object in an opaque proxy that warns you if you access any
35
- // of its properties.
34
+ /**
35
+ * Wrap a keyed object in an opaque proxy that warns you if you access any
36
+ * of its properties.
37
+ * See https://facebook.github.io/react/docs/create-fragment.html
38
+ */
39
create: function(object) {
40
if (typeof object !== 'object' || !object || Array.isArray(object)) {
41
warning(
src/addons/link/LinkedStateMixin.js
+1
@@ -16,6 +16,7 @@ var ReactStateSetters = require('ReactStateSetters');
16
17
/**
18
* A simple mixin around ReactLink.forState().
19
+ * See https://facebook.github.io/react/docs/two-way-binding-helpers.html
20
*/
21
var LinkedStateMixin = {
22
/**
src/addons/link/ReactLink.js
+3
@@ -37,6 +37,9 @@
37
var React = require('React');
38
39
/**
40
+ * Deprecated: An an easy way to express two-way binding with React.
41
+ * See https://facebook.github.io/react/docs/two-way-binding-helpers.html
42
+ *
43
* @param {*} value current value of the link
44
* @param {function} requestChange callback to request a change
45
*/
src/addons/shallowCompare.js
+1
@@ -16,6 +16,7 @@ var shallowEqual = require('shallowEqual');
16
/**
17
* Does a shallow comparison for props and state.
18
* See ReactComponentWithPureRenderMixin
19
+ * See also https://facebook.github.io/react/docs/shallow-compare.html
20
*/
21
function shallowCompare(instance, nextProps, nextState) {
22
return (
src/addons/transitions/ReactCSSTransitionGroup.js
+5
@@ -41,6 +41,11 @@ function createTransitionTimeoutPropValidator(transitionType) {
41
};
42
}
43
44
+/**
45
+ * An easy way to perform CSS transitions and animations when a React component
46
+ * enters or leaves the DOM.
47
+ * See https://facebook.github.io/react/docs/animation.html#high-level-api-reactcsstransitiongroup
48
+ */
49
var ReactCSSTransitionGroup = React.createClass({
50
displayName: 'ReactCSSTransitionGroup',
51
src/addons/transitions/ReactTransitionGroup.js
+5
@@ -16,6 +16,11 @@ var ReactTransitionChildMapping = require('ReactTransitionChildMapping');
16
17
var emptyFunction = require('emptyFunction');
18
19
+/**
20
+ * A basis for animatins. When children are declaratively added or removed,
21
+ * special lifecycle hooks are called.
22
+ * See https://facebook.github.io/react/docs/animation.html#low-level-api-reacttransitiongroup
23
+ */
24
var ReactTransitionGroup = React.createClass({
25
displayName: 'ReactTransitionGroup',
26
src/addons/update.js
+4
@@ -66,6 +66,10 @@ function invariantArrayCase(value, spec, command) {
66
);
67
}
68
69
+/**
70
+ * Returns a updated shallow copy of an object without mutating the original.
71
+ * See https://facebook.github.io/react/docs/update.html for details.
72
+ */
73
function update(value, spec) {
74
invariant(
75
typeof spec === 'object',
src/isomorphic/children/ReactChildren.js
+9
-1
@@ -55,6 +55,8 @@ function forEachSingleChild(bookKeeping, child, name) {
55
/**
56
* Iterates through children that are typically specified as `props.children`.
57
*
58
+ * See https://facebook.github.io/react/docs/top-level-api.html#react.children.foreach
59
+ *
60
* The provided forEachFunc(child, index) will be called for each
61
* leaf child.
62
*
@@ -146,7 +148,9 @@ function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
148
/**
149
* Maps children that are typically specified as `props.children`.
150
*
149
- * The provided mapFunction(child, index) will be called for each
151
+ * See https://facebook.github.io/react/docs/top-level-api.html#react.children.map
152
+ *
153
+ * The provided mapFunction(child, key, index) will be called for each
154
* leaf child.
155
*
156
* @param {?*} children Children tree container.
@@ -173,6 +177,8 @@ function forEachSingleChildDummy(traverseContext, child, name) {
177
* Count the number of children that are typically specified as
178
* `props.children`.
179
*
180
+ * See https://facebook.github.io/react/docs/top-level-api.html#react.children.count
181
+ *
182
* @param {?*} children Children tree container.
183
* @return {number} The number of children.
184
*/
@@ -184,6 +190,8 @@ function countChildren(children, context) {
190
/**
191
* Flatten a children object (typically specified as `props.children`) and
192
* return an array with appropriately re-keyed children.
193
+ *
194
+ * See https://facebook.github.io/react/docs/top-level-api.html#react.children.toarray
195
*/
196
function toArray(children) {
197
var result = [];
src/isomorphic/children/onlyChild.js
+7
-4
@@ -16,10 +16,13 @@ var invariant = require('invariant');
16
17
/**
18
* Returns the first child in a collection of children and verifies that there
19
- * is only one child in the collection. The current implementation of this
20
- * function assumes that a single child gets passed without a wrapper, but the
21
- * purpose of this helper function is to abstract away the particular structure
22
- * of children.
19
+ * is only one child in the collection.
20
+ *
21
+ * See https://facebook.github.io/react/docs/top-level-api.html#react.children.only
22
+ *
23
+ * The current implementation of this function assumes that a single child gets
24
+ * passed without a wrapper, but the purpose of this helper function is to
25
+ * abstract away the particular structure of children.
26
*
27
* @param {?object} children Child collection structure.
28
* @return {ReactElement} The first and only `ReactElement` contained in the
src/isomorphic/classic/class/ReactClass.js
+1
@@ -740,6 +740,7 @@ var ReactClass = {
740
741
/**
742
* Creates a composite component class given a class specification.
743
+ * See https://facebook.github.io/react/docs/top-level-api.html#react.createclass
744
*
745
* @param {object} spec Class specification (which must define `render`).
746
* @return {function} Component constructor function.
src/isomorphic/classic/element/ReactElement.js
+14
@@ -113,6 +113,10 @@ var ReactElement = function(type, key, ref, self, source, owner, props) {
113
return element;
114
};
115
116
+/**
117
+ * Create and return a new ReactElement of the given type.
118
+ * See https://facebook.github.io/react/docs/top-level-api.html#react.createelement
119
+ */
120
ReactElement.createElement = function(type, config, children) {
121
var propName;
122
@@ -230,6 +234,10 @@ ReactElement.createElement = function(type, config, children) {
234
);
235
};
236
237
+/**
238
+ * Return a function that produces ReactElements of a given type.
239
+ * See https://facebook.github.io/react/docs/top-level-api.html#react.createfactory
240
+ */
241
ReactElement.createFactory = function(type) {
242
var factory = ReactElement.createElement.bind(null, type);
243
// Expose the type on the factory and the prototype so that it can be
@@ -255,6 +263,10 @@ ReactElement.cloneAndReplaceKey = function(oldElement, newKey) {
263
return newElement;
264
};
265
266
+/**
267
+ * Clone and return a new ReactElement using element as the starting point.
268
+ * See https://facebook.github.io/react/docs/top-level-api.html#react.cloneelement
269
+ */
270
ReactElement.cloneElement = function(element, config, children) {
271
var propName;
272
@@ -335,6 +347,8 @@ ReactElement.cloneElement = function(element, config, children) {
347
};
348
349
/**
350
+ * Verifies the object is a ReactElement.
351
+ * See https://facebook.github.io/react/docs/top-level-api.html#react.isvalidelement
352
* @param {?object} object
353
* @return {boolean} True if `object` is a valid component.
354
* @final
src/renderers/dom/client/ReactMount.js
+2
@@ -511,6 +511,7 @@ var ReactMount = {
511
512
/**
513
* Renders a React component into the DOM in the supplied `container`.
514
+ * See https://facebook.github.io/react/docs/top-level-api.html#reactdom.render
515
*
516
* If the React component was previously rendered into `container`, this will
517
* perform an update on it and only mutate the DOM as necessary to reflect the
@@ -527,6 +528,7 @@ var ReactMount = {
528
529
/**
530
* Unmounts and destroys the React component rendered in the `container`.
531
+ * See https://facebook.github.io/react/docs/top-level-api.html#reactdom.unmountcomponentatnode
532
*
533
* @param {DOMElement} container DOM element containing a React component.
534
* @return {boolean} True if a component was found in and unmounted from
src/renderers/dom/client/findDOMNode.js
+2
@@ -22,6 +22,8 @@ var warning = require('warning');
22
/**
23
* Returns the DOM node rendered by this element.
24
*
25
+ * See https://facebook.github.io/react/docs/top-level-api.html#reactdom.finddomnode
26
+ *
27
* @param {ReactComponent|DOMElement} componentOrElement
28
* @return {?DOMElement} The root node of this element.
29
*/
src/renderers/dom/server/ReactServerRendering.js
+10
@@ -63,6 +63,11 @@ function renderToStringImpl(element, makeStaticMarkup) {
63
}
64
}
65
66
+/**
67
+ * Render a ReactElement to its initial HTML. This should only be used on the
68
+ * server.
69
+ * See https://facebook.github.io/react/docs/top-level-api.html#reactdomserver.rendertostring
70
+ */
71
function renderToString(element) {
72
invariant(
73
ReactElement.isValidElement(element),
@@ -71,6 +76,11 @@ function renderToString(element) {
76
return renderToStringImpl(element, false);
77
}
78
79
+/**
80
+ * Similar to renderToString, except this doesn't create extra DOM attributes
81
+ * such as data-react-id that React uses internally.
82
+ * See https://facebook.github.io/react/docs/top-level-api.html#reactdomserver.rendertostaticmarkup
83
+ */
84
function renderToStaticMarkup(element) {
85
invariant(
86
ReactElement.isValidElement(element),
src/test/ReactPerf.js
+1
@@ -14,6 +14,7 @@
14
/**
15
* ReactPerf is a general AOP system designed to measure performance. This
16
* module only has the hooks: see ReactDefaultPerf for the analysis tool.
17
+ * See also https://facebook.github.io/react/docs/perf.html
18
*/
19
var ReactPerf = {
20
/**
src/test/ReactTestUtils.js
+4
@@ -71,6 +71,10 @@ function findAllInRenderedTreeInternal(inst, test) {
71
}
72
73
/**
74
+ * Utilities for making it easy to test React components.
75
+ *
76
+ * See https://facebook.github.io/react/docs/test-utils.html
77
+ *
78
* Todo: Support the entire DOM.scry query syntax. For now, these simple
79
* utilities will suffice for testing purposes.
80
* @lends ReactTestUtils