react 15.6.0 → 16.0.0-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +7 -0
  2. package/dist/react-with-addons.js +3813 -4283
  3. package/dist/react-with-addons.min.js +2 -3
  4. package/dist/react.js +2882 -3136
  5. package/dist/react.min.js +2 -2
  6. package/lib/React.js +15 -58
  7. package/lib/ReactCSSTransitionGroup.js +4 -6
  8. package/lib/ReactCSSTransitionGroupChild.js +113 -131
  9. package/lib/ReactChildren.js +4 -4
  10. package/lib/ReactClass.js +703 -0
  11. package/lib/{ReactBaseClasses.js → ReactComponent.js} +6 -37
  12. package/lib/ReactComponentTreeHook.js +58 -55
  13. package/lib/ReactCurrentOwner.js +2 -0
  14. package/lib/ReactDOMFactories.js +1 -0
  15. package/lib/ReactElement.js +4 -4
  16. package/lib/ReactElementValidator.js +8 -9
  17. package/lib/ReactNoopUpdateQueue.js +10 -13
  18. package/lib/ReactPropTypes.js +442 -4
  19. package/lib/ReactPureComponent.js +41 -0
  20. package/lib/ReactTransitionGroup.js +3 -9
  21. package/lib/ReactTypeOfWork.js +26 -0
  22. package/lib/ReactUMDEntry.js +3 -4
  23. package/lib/ReactVersion.js +1 -1
  24. package/lib/ReactWithAddons.js +0 -2
  25. package/lib/ReactWithAddonsUMDEntry.js +3 -4
  26. package/lib/checkReactTypeSpec.js +17 -6
  27. package/lib/deprecated.js +3 -3
  28. package/lib/getComponentName.js +37 -0
  29. package/lib/onlyChild.js +1 -1
  30. package/lib/traverseAllChildren.js +1 -1
  31. package/package.json +3 -5
  32. package/lib/LinkedStateMixin.js +0 -34
  33. package/lib/ReactComponentTreeDevtool.js +0 -14
  34. package/lib/ReactLink.js +0 -50
  35. package/lib/ReactPropTypesSecret.js +0 -16
  36. package/lib/createClass.js +0 -22
  37. package/lib/getNextDebugIDUMDShim.js +0 -17
  38. package/lib/lowPriorityWarning.js +0 -64
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Copyright 2013-present, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ *
9
+ */
10
+
11
+ 'use strict';
12
+
13
+ var _assign = require('object-assign');
14
+
15
+ var ReactComponent = require('./ReactComponent');
16
+ var ReactNoopUpdateQueue = require('./ReactNoopUpdateQueue');
17
+
18
+ var emptyObject = require('fbjs/lib/emptyObject');
19
+
20
+ /**
21
+ * Base class helpers for the updating state of a component.
22
+ */
23
+ function ReactPureComponent(props, context, updater) {
24
+ // Duplicated from ReactComponent.
25
+ this.props = props;
26
+ this.context = context;
27
+ this.refs = emptyObject;
28
+ // We initialize the default updater but the real one gets injected by the
29
+ // renderer.
30
+ this.updater = updater || ReactNoopUpdateQueue;
31
+ }
32
+
33
+ function ComponentDummy() {}
34
+ ComponentDummy.prototype = ReactComponent.prototype;
35
+ ReactPureComponent.prototype = new ComponentDummy();
36
+ ReactPureComponent.prototype.constructor = ReactPureComponent;
37
+ // Avoid an extra prototype jump for these methods.
38
+ _assign(ReactPureComponent.prototype, ReactComponent.prototype);
39
+ ReactPureComponent.prototype.isPureReactComponent = true;
40
+
41
+ module.exports = ReactPureComponent;
@@ -21,9 +21,6 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
21
21
  var React = require('./React');
22
22
  var ReactTransitionChildMapping = require('./ReactTransitionChildMapping');
23
23
 
24
- var propTypesFactory = require('prop-types/factory');
25
- var PropTypes = propTypesFactory(React.isValidElement);
26
-
27
24
  var emptyFunction = require('fbjs/lib/emptyFunction');
28
25
 
29
26
  /**
@@ -195,10 +192,7 @@ var ReactTransitionGroup = function (_React$Component) {
195
192
  // already been removed. In case you need this behavior you can provide
196
193
  // a childFactory function to wrap every child, even the ones that are
197
194
  // leaving.
198
- childrenToRender.push(React.cloneElement(this.props.childFactory(child), {
199
- ref: key,
200
- key: key
201
- }));
195
+ childrenToRender.push(React.cloneElement(this.props.childFactory(child), { ref: key, key: key }));
202
196
  }
203
197
  }
204
198
 
@@ -222,8 +216,8 @@ var ReactTransitionGroup = function (_React$Component) {
222
216
 
223
217
  ReactTransitionGroup.displayName = 'ReactTransitionGroup';
224
218
  ReactTransitionGroup.propTypes = {
225
- component: PropTypes.any,
226
- childFactory: PropTypes.func
219
+ component: React.PropTypes.any,
220
+ childFactory: React.PropTypes.func
227
221
  };
228
222
  ReactTransitionGroup.defaultProps = {
229
223
  component: 'span',
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Copyright 2013-present, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ *
9
+ *
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ module.exports = {
15
+ IndeterminateComponent: 0, // Before we know whether it is functional or class
16
+ FunctionalComponent: 1,
17
+ ClassComponent: 2,
18
+ HostRoot: 3, // Root of a host tree. Could be nested inside another node.
19
+ HostPortal: 4, // A subtree. Could be an entry point to a different renderer.
20
+ HostComponent: 5,
21
+ HostText: 6,
22
+ CoroutineComponent: 7,
23
+ CoroutineHandlerPhase: 8,
24
+ YieldComponent: 9,
25
+ Fragment: 10
26
+ };
@@ -15,17 +15,16 @@ var _assign = require('object-assign');
15
15
  var React = require('./React');
16
16
 
17
17
  // `version` will be added here by the React module.
18
- var ReactUMDEntry = _assign(React, {
18
+ var ReactUMDEntry = _assign({
19
19
  __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: {
20
20
  ReactCurrentOwner: require('./ReactCurrentOwner')
21
21
  }
22
- });
22
+ }, React);
23
23
 
24
24
  if (process.env.NODE_ENV !== 'production') {
25
25
  _assign(ReactUMDEntry.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, {
26
26
  // ReactComponentTreeHook should not be included in production.
27
- ReactComponentTreeHook: require('./ReactComponentTreeHook'),
28
- getNextDebugID: require('./getNextDebugID')
27
+ ReactComponentTreeHook: require('./ReactComponentTreeHook')
29
28
  });
30
29
  }
31
30
 
@@ -10,4 +10,4 @@
10
10
 
11
11
  'use strict';
12
12
 
13
- module.exports = '15.6.0';
13
+ module.exports = '16.0.0-alpha';
@@ -10,7 +10,6 @@
10
10
 
11
11
  'use strict';
12
12
 
13
- var LinkedStateMixin = require('./LinkedStateMixin');
14
13
  var React = require('./React');
15
14
  var ReactAddonsDOMDependencies = require('./ReactAddonsDOMDependencies');
16
15
  var ReactComponentWithPureRenderMixin = require('./ReactComponentWithPureRenderMixin');
@@ -23,7 +22,6 @@ var update = require('./update');
23
22
 
24
23
  React.addons = {
25
24
  CSSTransitionGroup: ReactCSSTransitionGroup,
26
- LinkedStateMixin: LinkedStateMixin,
27
25
  PureRenderMixin: ReactComponentWithPureRenderMixin,
28
26
  TransitionGroup: ReactTransitionGroup,
29
27
 
@@ -15,18 +15,17 @@ var _assign = require('object-assign');
15
15
  var ReactWithAddons = require('./ReactWithAddons');
16
16
 
17
17
  // `version` will be added here by the React module.
18
- var ReactWithAddonsUMDEntry = _assign(ReactWithAddons, {
18
+ var ReactWithAddonsUMDEntry = _assign({
19
19
  __SECRET_INJECTED_REACT_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: null, // Will be injected by ReactDOM UMD build.
20
20
  __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: {
21
21
  ReactCurrentOwner: require('./ReactCurrentOwner')
22
22
  }
23
- });
23
+ }, ReactWithAddons);
24
24
 
25
25
  if (process.env.NODE_ENV !== 'production') {
26
26
  _assign(ReactWithAddonsUMDEntry.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, {
27
27
  // ReactComponentTreeHook should not be included in production.
28
- ReactComponentTreeHook: require('./ReactComponentTreeHook'),
29
- getNextDebugID: require('./getNextDebugID')
28
+ ReactComponentTreeHook: require('./ReactComponentTreeHook')
30
29
  });
31
30
  }
32
31
 
@@ -13,7 +13,6 @@
13
13
  var _prodInvariant = require('./reactProdInvariant');
14
14
 
15
15
  var ReactPropTypeLocationNames = require('./ReactPropTypeLocationNames');
16
- var ReactPropTypesSecret = require('./ReactPropTypesSecret');
17
16
 
18
17
  var invariant = require('fbjs/lib/invariant');
19
18
  var warning = require('fbjs/lib/warning');
@@ -40,10 +39,12 @@ var loggedTypeFailures = {};
40
39
  * @param {string} location e.g. "prop", "context", "child context"
41
40
  * @param {string} componentName Name of the component for error messages.
42
41
  * @param {?object} element The React element that is being type-checked
43
- * @param {?number} debugID The React component instance that is being type-checked
42
+ * @param {?number} workInProgressOrDebugID The React component instance that is being type-checked
44
43
  * @private
45
44
  */
46
- function checkReactTypeSpec(typeSpecs, values, location, componentName, element, debugID) {
45
+ function checkReactTypeSpec(typeSpecs, values, location, componentName, element,
46
+ // It is only safe to pass fiber if it is the work-in-progress version, and
47
+ workInProgressOrDebugID) {
47
48
  for (var typeSpecName in typeSpecs) {
48
49
  if (typeSpecs.hasOwnProperty(typeSpecName)) {
49
50
  var error;
@@ -54,7 +55,7 @@ function checkReactTypeSpec(typeSpecs, values, location, componentName, element,
54
55
  // This is intentionally an invariant that gets caught. It's the same
55
56
  // behavior as without this statement except with a better message.
56
57
  !(typeof typeSpecs[typeSpecName] === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s: %s type `%s` is invalid; it must be a function, usually from React.PropTypes.', componentName || 'React class', ReactPropTypeLocationNames[location], typeSpecName) : _prodInvariant('84', componentName || 'React class', ReactPropTypeLocationNames[location], typeSpecName) : void 0;
57
- error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
58
+ error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location);
58
59
  } catch (ex) {
59
60
  error = ex;
60
61
  }
@@ -70,8 +71,18 @@ function checkReactTypeSpec(typeSpecs, values, location, componentName, element,
70
71
  if (!ReactComponentTreeHook) {
71
72
  ReactComponentTreeHook = require('./ReactComponentTreeHook');
72
73
  }
73
- if (debugID !== null) {
74
- componentStackInfo = ReactComponentTreeHook.getStackAddendumByID(debugID);
74
+ if (workInProgressOrDebugID != null) {
75
+ if (typeof workInProgressOrDebugID === 'number') {
76
+ // DebugID from Stack.
77
+ var debugID = workInProgressOrDebugID;
78
+ componentStackInfo = ReactComponentTreeHook.getStackAddendumByID(debugID);
79
+ } else if (typeof workInProgressOrDebugID.tag === 'number') {
80
+ // This is a Fiber.
81
+ // The stack will only be correct if this is a work in progress
82
+ // version and we're calling it during reconciliation.
83
+ var workInProgress = workInProgressOrDebugID;
84
+ componentStackInfo = ReactComponentTreeHook.getStackAddendumByWorkInProgressFiber(workInProgress);
85
+ }
75
86
  } else if (element !== null) {
76
87
  componentStackInfo = ReactComponentTreeHook.getCurrentStackAddendum(element);
77
88
  }
package/lib/deprecated.js CHANGED
@@ -13,7 +13,7 @@
13
13
 
14
14
  var _assign = require('object-assign');
15
15
 
16
- var lowPriorityWarning = require('./lowPriorityWarning');
16
+ var warning = require('fbjs/lib/warning');
17
17
 
18
18
  /**
19
19
  * This will log a single deprecation notice per function and forward the call
@@ -30,12 +30,12 @@ function deprecated(fnName, newModule, newPackage, ctx, fn) {
30
30
  var warned = false;
31
31
  if (process.env.NODE_ENV !== 'production') {
32
32
  var newFn = function () {
33
- lowPriorityWarning(warned,
33
+ process.env.NODE_ENV !== 'production' ? warning(warned,
34
34
  /* eslint-disable no-useless-concat */
35
35
  // Require examples in this string must be split to prevent React's
36
36
  // build tools from mistaking them for real requires.
37
37
  // Otherwise the build tools will attempt to build a '%s' module.
38
- 'React.%s is deprecated. Please use %s.%s from require' + "('%s') " + 'instead.', fnName, newModule, fnName, newPackage);
38
+ 'React.%s is deprecated. Please use %s.%s from require' + '(\'%s\') ' + 'instead.', fnName, newModule, fnName, newPackage) : void 0;
39
39
  /* eslint-enable no-useless-concat */
40
40
  warned = true;
41
41
  return fn.apply(ctx, arguments);
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Copyright 2013-present, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ *
9
+ *
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ function getComponentName(instanceOrFiber) {
15
+ if (process.env.NODE_ENV !== 'production') {
16
+ if (typeof instanceOrFiber.getName === 'function') {
17
+ // Stack reconciler
18
+ var instance = instanceOrFiber;
19
+ return instance.getName() || 'Component';
20
+ }
21
+ if (typeof instanceOrFiber.tag === 'number') {
22
+ // Fiber reconciler
23
+ var fiber = instanceOrFiber;
24
+ var type = fiber.type;
25
+
26
+ if (typeof type === 'string') {
27
+ return type;
28
+ }
29
+ if (typeof type === 'function') {
30
+ return type.displayName || type.name || null;
31
+ }
32
+ }
33
+ }
34
+ return null;
35
+ }
36
+
37
+ module.exports = getComponentName;
package/lib/onlyChild.js CHANGED
@@ -19,7 +19,7 @@ var invariant = require('fbjs/lib/invariant');
19
19
  * Returns the first child in a collection of children and verifies that there
20
20
  * is only one child in the collection.
21
21
  *
22
- * See https://facebook.github.io/react/docs/top-level-api.html#react.children.only
22
+ * See https://facebook.github.io/react/docs/react-api.html#react.children.only
23
23
  *
24
24
  * The current implementation of this function assumes that a single child gets
25
25
  * passed without a wrapper, but the purpose of this helper function is to
@@ -131,7 +131,7 @@ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext)
131
131
  if (process.env.NODE_ENV !== 'production') {
132
132
  addendum = ' If you meant to render a collection of children, use an array ' + 'instead or wrap the object using createFragment(object) from the ' + 'React add-ons.';
133
133
  if (children._isReactElement) {
134
- addendum = " It looks like you're using an element created by a different " + 'version of React. Make sure to use only one copy of React.';
134
+ addendum = ' It looks like you\'re using an element created by a different ' + 'version of React. Make sure to use only one copy of React.';
135
135
  }
136
136
  if (ReactCurrentOwner.current) {
137
137
  var name = ReactCurrentOwner.current.getName();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react",
3
3
  "description": "React is a JavaScript library for building user interfaces.",
4
- "version": "15.6.0",
4
+ "version": "16.0.0-alpha",
5
5
  "keywords": [
6
6
  "react"
7
7
  ],
@@ -23,11 +23,9 @@
23
23
  "node": ">=0.10.0"
24
24
  },
25
25
  "dependencies": {
26
- "create-react-class": "^15.5.2",
27
- "fbjs": "^0.8.9",
26
+ "fbjs": "^0.8.4",
28
27
  "loose-envify": "^1.1.0",
29
- "object-assign": "^4.1.0",
30
- "prop-types": "^15.5.7"
28
+ "object-assign": "^4.1.0"
31
29
  },
32
30
  "browserify": {
33
31
  "transform": [
@@ -1,34 +0,0 @@
1
- /**
2
- * Copyright 2013-present, Facebook, Inc.
3
- * All rights reserved.
4
- *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
8
- *
9
- */
10
-
11
- 'use strict';
12
-
13
- var ReactLink = require('./ReactLink');
14
- var ReactStateSetters = require('./ReactStateSetters');
15
-
16
- /**
17
- * A simple mixin around ReactLink.forState().
18
- * See https://facebook.github.io/react/docs/two-way-binding-helpers.html
19
- */
20
- var LinkedStateMixin = {
21
- /**
22
- * Create a ReactLink that's linked to part of this component's state. The
23
- * ReactLink will have the current value of this.state[key] and will call
24
- * setState() when a change is requested.
25
- *
26
- * @param {string} key state key to update.
27
- * @return {ReactLink} ReactLink instance linking to the state.
28
- */
29
- linkState: function (key) {
30
- return new ReactLink(this.state[key], ReactStateSetters.createStateKeySetter(this, key));
31
- }
32
- };
33
-
34
- module.exports = LinkedStateMixin;
@@ -1,14 +0,0 @@
1
- /**
2
- * Copyright 2016-present, Facebook, Inc.
3
- * All rights reserved.
4
- *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
8
- *
9
- */
10
- 'use strict';
11
-
12
- // TODO remove this proxy when RN/www gets updated
13
-
14
- module.exports = require('./ReactComponentTreeHook');
package/lib/ReactLink.js DELETED
@@ -1,50 +0,0 @@
1
- /**
2
- * Copyright 2013-present, Facebook, Inc.
3
- * All rights reserved.
4
- *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
8
- *
9
- */
10
-
11
- 'use strict';
12
-
13
- /**
14
- * ReactLink encapsulates a common pattern in which a component wants to modify
15
- * a prop received from its parent. ReactLink allows the parent to pass down a
16
- * value coupled with a callback that, when invoked, expresses an intent to
17
- * modify that value. For example:
18
- *
19
- * React.createClass({
20
- * getInitialState: function() {
21
- * return {value: ''};
22
- * },
23
- * render: function() {
24
- * var valueLink = new ReactLink(this.state.value, this._handleValueChange);
25
- * return <input valueLink={valueLink} />;
26
- * },
27
- * _handleValueChange: function(newValue) {
28
- * this.setState({value: newValue});
29
- * }
30
- * });
31
- *
32
- * We have provided some sugary mixins to make the creation and
33
- * consumption of ReactLink easier; see LinkedValueUtils and LinkedStateMixin.
34
- */
35
-
36
- var React = require('./React');
37
-
38
- /**
39
- * Deprecated: An an easy way to express two-way binding with React.
40
- * See https://facebook.github.io/react/docs/two-way-binding-helpers.html
41
- *
42
- * @param {*} value current value of the link
43
- * @param {function} requestChange callback to request a change
44
- */
45
- function ReactLink(value, requestChange) {
46
- this.value = value;
47
- this.requestChange = requestChange;
48
- }
49
-
50
- module.exports = ReactLink;
@@ -1,16 +0,0 @@
1
- /**
2
- * Copyright 2013-present, Facebook, Inc.
3
- * All rights reserved.
4
- *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
8
- *
9
- *
10
- */
11
-
12
- 'use strict';
13
-
14
- var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
15
-
16
- module.exports = ReactPropTypesSecret;