react 15.5.0-rc.1 → 15.5.2

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.
@@ -1,712 +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 _prodInvariant = require('./reactProdInvariant'),
14
- _assign = require('object-assign');
15
-
16
- var ReactComponent = require('./ReactComponent');
17
- var ReactElement = require('./ReactElement');
18
- var ReactPropTypeLocationNames = require('./ReactPropTypeLocationNames');
19
- var ReactNoopUpdateQueue = require('./ReactNoopUpdateQueue');
20
-
21
- var emptyObject = require('fbjs/lib/emptyObject');
22
- var _invariant = require('fbjs/lib/invariant');
23
-
24
- if (process.env.NODE_ENV !== 'production') {
25
- var warning = require('fbjs/lib/warning');
26
- }
27
-
28
- var MIXINS_KEY = 'mixins';
29
-
30
- // Helper function to allow the creation of anonymous functions which do not
31
- // have .name set to the name of the variable being assigned to.
32
- function identity(fn) {
33
- return fn;
34
- }
35
-
36
- /**
37
- * Policies that describe methods in `ReactClassInterface`.
38
- */
39
-
40
-
41
- var injectedMixins = [];
42
-
43
- /**
44
- * Composite components are higher-level components that compose other composite
45
- * or host components.
46
- *
47
- * To create a new type of `ReactClass`, pass a specification of
48
- * your new class to `React.createClass`. The only requirement of your class
49
- * specification is that you implement a `render` method.
50
- *
51
- * var MyComponent = React.createClass({
52
- * render: function() {
53
- * return <div>Hello World</div>;
54
- * }
55
- * });
56
- *
57
- * The class specification supports a specific protocol of methods that have
58
- * special meaning (e.g. `render`). See `ReactClassInterface` for
59
- * more the comprehensive protocol. Any other properties and methods in the
60
- * class specification will be available on the prototype.
61
- *
62
- * @interface ReactClassInterface
63
- * @internal
64
- */
65
- var ReactClassInterface = {
66
- /**
67
- * An array of Mixin objects to include when defining your component.
68
- *
69
- * @type {array}
70
- * @optional
71
- */
72
- mixins: 'DEFINE_MANY',
73
-
74
- /**
75
- * An object containing properties and methods that should be defined on
76
- * the component's constructor instead of its prototype (static methods).
77
- *
78
- * @type {object}
79
- * @optional
80
- */
81
- statics: 'DEFINE_MANY',
82
-
83
- /**
84
- * Definition of prop types for this component.
85
- *
86
- * @type {object}
87
- * @optional
88
- */
89
- propTypes: 'DEFINE_MANY',
90
-
91
- /**
92
- * Definition of context types for this component.
93
- *
94
- * @type {object}
95
- * @optional
96
- */
97
- contextTypes: 'DEFINE_MANY',
98
-
99
- /**
100
- * Definition of context types this component sets for its children.
101
- *
102
- * @type {object}
103
- * @optional
104
- */
105
- childContextTypes: 'DEFINE_MANY',
106
-
107
- // ==== Definition methods ====
108
-
109
- /**
110
- * Invoked when the component is mounted. Values in the mapping will be set on
111
- * `this.props` if that prop is not specified (i.e. using an `in` check).
112
- *
113
- * This method is invoked before `getInitialState` and therefore cannot rely
114
- * on `this.state` or use `this.setState`.
115
- *
116
- * @return {object}
117
- * @optional
118
- */
119
- getDefaultProps: 'DEFINE_MANY_MERGED',
120
-
121
- /**
122
- * Invoked once before the component is mounted. The return value will be used
123
- * as the initial value of `this.state`.
124
- *
125
- * getInitialState: function() {
126
- * return {
127
- * isOn: false,
128
- * fooBaz: new BazFoo()
129
- * }
130
- * }
131
- *
132
- * @return {object}
133
- * @optional
134
- */
135
- getInitialState: 'DEFINE_MANY_MERGED',
136
-
137
- /**
138
- * @return {object}
139
- * @optional
140
- */
141
- getChildContext: 'DEFINE_MANY_MERGED',
142
-
143
- /**
144
- * Uses props from `this.props` and state from `this.state` to render the
145
- * structure of the component.
146
- *
147
- * No guarantees are made about when or how often this method is invoked, so
148
- * it must not have side effects.
149
- *
150
- * render: function() {
151
- * var name = this.props.name;
152
- * return <div>Hello, {name}!</div>;
153
- * }
154
- *
155
- * @return {ReactComponent}
156
- * @nosideeffects
157
- * @required
158
- */
159
- render: 'DEFINE_ONCE',
160
-
161
- // ==== Delegate methods ====
162
-
163
- /**
164
- * Invoked when the component is initially created and about to be mounted.
165
- * This may have side effects, but any external subscriptions or data created
166
- * by this method must be cleaned up in `componentWillUnmount`.
167
- *
168
- * @optional
169
- */
170
- componentWillMount: 'DEFINE_MANY',
171
-
172
- /**
173
- * Invoked when the component has been mounted and has a DOM representation.
174
- * However, there is no guarantee that the DOM node is in the document.
175
- *
176
- * Use this as an opportunity to operate on the DOM when the component has
177
- * been mounted (initialized and rendered) for the first time.
178
- *
179
- * @param {DOMElement} rootNode DOM element representing the component.
180
- * @optional
181
- */
182
- componentDidMount: 'DEFINE_MANY',
183
-
184
- /**
185
- * Invoked before the component receives new props.
186
- *
187
- * Use this as an opportunity to react to a prop transition by updating the
188
- * state using `this.setState`. Current props are accessed via `this.props`.
189
- *
190
- * componentWillReceiveProps: function(nextProps, nextContext) {
191
- * this.setState({
192
- * likesIncreasing: nextProps.likeCount > this.props.likeCount
193
- * });
194
- * }
195
- *
196
- * NOTE: There is no equivalent `componentWillReceiveState`. An incoming prop
197
- * transition may cause a state change, but the opposite is not true. If you
198
- * need it, you are probably looking for `componentWillUpdate`.
199
- *
200
- * @param {object} nextProps
201
- * @optional
202
- */
203
- componentWillReceiveProps: 'DEFINE_MANY',
204
-
205
- /**
206
- * Invoked while deciding if the component should be updated as a result of
207
- * receiving new props, state and/or context.
208
- *
209
- * Use this as an opportunity to `return false` when you're certain that the
210
- * transition to the new props/state/context will not require a component
211
- * update.
212
- *
213
- * shouldComponentUpdate: function(nextProps, nextState, nextContext) {
214
- * return !equal(nextProps, this.props) ||
215
- * !equal(nextState, this.state) ||
216
- * !equal(nextContext, this.context);
217
- * }
218
- *
219
- * @param {object} nextProps
220
- * @param {?object} nextState
221
- * @param {?object} nextContext
222
- * @return {boolean} True if the component should update.
223
- * @optional
224
- */
225
- shouldComponentUpdate: 'DEFINE_ONCE',
226
-
227
- /**
228
- * Invoked when the component is about to update due to a transition from
229
- * `this.props`, `this.state` and `this.context` to `nextProps`, `nextState`
230
- * and `nextContext`.
231
- *
232
- * Use this as an opportunity to perform preparation before an update occurs.
233
- *
234
- * NOTE: You **cannot** use `this.setState()` in this method.
235
- *
236
- * @param {object} nextProps
237
- * @param {?object} nextState
238
- * @param {?object} nextContext
239
- * @param {ReactReconcileTransaction} transaction
240
- * @optional
241
- */
242
- componentWillUpdate: 'DEFINE_MANY',
243
-
244
- /**
245
- * Invoked when the component's DOM representation has been updated.
246
- *
247
- * Use this as an opportunity to operate on the DOM when the component has
248
- * been updated.
249
- *
250
- * @param {object} prevProps
251
- * @param {?object} prevState
252
- * @param {?object} prevContext
253
- * @param {DOMElement} rootNode DOM element representing the component.
254
- * @optional
255
- */
256
- componentDidUpdate: 'DEFINE_MANY',
257
-
258
- /**
259
- * Invoked when the component is about to be removed from its parent and have
260
- * its DOM representation destroyed.
261
- *
262
- * Use this as an opportunity to deallocate any external resources.
263
- *
264
- * NOTE: There is no `componentDidUnmount` since your component will have been
265
- * destroyed by that point.
266
- *
267
- * @optional
268
- */
269
- componentWillUnmount: 'DEFINE_MANY',
270
-
271
- // ==== Advanced methods ====
272
-
273
- /**
274
- * Updates the component's currently mounted DOM representation.
275
- *
276
- * By default, this implements React's rendering and reconciliation algorithm.
277
- * Sophisticated clients may wish to override this.
278
- *
279
- * @param {ReactReconcileTransaction} transaction
280
- * @internal
281
- * @overridable
282
- */
283
- updateComponent: 'OVERRIDE_BASE'
284
- };
285
-
286
- /**
287
- * Mapping from class specification keys to special processing functions.
288
- *
289
- * Although these are declared like instance properties in the specification
290
- * when defining classes using `React.createClass`, they are actually static
291
- * and are accessible on the constructor instead of the prototype. Despite
292
- * being static, they must be defined outside of the "statics" key under
293
- * which all other static methods are defined.
294
- */
295
- var RESERVED_SPEC_KEYS = {
296
- displayName: function (Constructor, displayName) {
297
- Constructor.displayName = displayName;
298
- },
299
- mixins: function (Constructor, mixins) {
300
- if (mixins) {
301
- for (var i = 0; i < mixins.length; i++) {
302
- mixSpecIntoComponent(Constructor, mixins[i]);
303
- }
304
- }
305
- },
306
- childContextTypes: function (Constructor, childContextTypes) {
307
- if (process.env.NODE_ENV !== 'production') {
308
- validateTypeDef(Constructor, childContextTypes, 'childContext');
309
- }
310
- Constructor.childContextTypes = _assign({}, Constructor.childContextTypes, childContextTypes);
311
- },
312
- contextTypes: function (Constructor, contextTypes) {
313
- if (process.env.NODE_ENV !== 'production') {
314
- validateTypeDef(Constructor, contextTypes, 'context');
315
- }
316
- Constructor.contextTypes = _assign({}, Constructor.contextTypes, contextTypes);
317
- },
318
- /**
319
- * Special case getDefaultProps which should move into statics but requires
320
- * automatic merging.
321
- */
322
- getDefaultProps: function (Constructor, getDefaultProps) {
323
- if (Constructor.getDefaultProps) {
324
- Constructor.getDefaultProps = createMergedResultFunction(Constructor.getDefaultProps, getDefaultProps);
325
- } else {
326
- Constructor.getDefaultProps = getDefaultProps;
327
- }
328
- },
329
- propTypes: function (Constructor, propTypes) {
330
- if (process.env.NODE_ENV !== 'production') {
331
- validateTypeDef(Constructor, propTypes, 'prop');
332
- }
333
- Constructor.propTypes = _assign({}, Constructor.propTypes, propTypes);
334
- },
335
- statics: function (Constructor, statics) {
336
- mixStaticSpecIntoComponent(Constructor, statics);
337
- },
338
- autobind: function () {} };
339
-
340
- function validateTypeDef(Constructor, typeDef, location) {
341
- for (var propName in typeDef) {
342
- if (typeDef.hasOwnProperty(propName)) {
343
- // use a warning instead of an _invariant so components
344
- // don't show up in prod but only in __DEV__
345
- process.env.NODE_ENV !== 'production' ? warning(typeof typeDef[propName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', Constructor.displayName || 'ReactClass', ReactPropTypeLocationNames[location], propName) : void 0;
346
- }
347
- }
348
- }
349
-
350
- function validateMethodOverride(isAlreadyDefined, name) {
351
- var specPolicy = ReactClassInterface.hasOwnProperty(name) ? ReactClassInterface[name] : null;
352
-
353
- // Disallow overriding of base class methods unless explicitly allowed.
354
- if (ReactClassMixin.hasOwnProperty(name)) {
355
- _invariant(specPolicy === 'OVERRIDE_BASE', 'ReactClassInterface: You are attempting to override ' + '`%s` from your class specification. Ensure that your method names ' + 'do not overlap with React methods.', name);
356
- }
357
-
358
- // Disallow defining methods more than once unless explicitly allowed.
359
- if (isAlreadyDefined) {
360
- _invariant(specPolicy === 'DEFINE_MANY' || specPolicy === 'DEFINE_MANY_MERGED', 'ReactClassInterface: You are attempting to define ' + '`%s` on your component more than once. This conflict may be due ' + 'to a mixin.', name);
361
- }
362
- }
363
-
364
- /**
365
- * Mixin helper which handles policy validation and reserved
366
- * specification keys when building React classes.
367
- */
368
- function mixSpecIntoComponent(Constructor, spec) {
369
- if (!spec) {
370
- if (process.env.NODE_ENV !== 'production') {
371
- var typeofSpec = typeof spec;
372
- var isMixinValid = typeofSpec === 'object' && spec !== null;
373
-
374
- process.env.NODE_ENV !== 'production' ? warning(isMixinValid, "%s: You're attempting to include a mixin that is either null " + 'or not an object. Check the mixins included by the component, ' + 'as well as any mixins they include themselves. ' + 'Expected object but got %s.', Constructor.displayName || 'ReactClass', spec === null ? null : typeofSpec) : void 0;
375
- }
376
-
377
- return;
378
- }
379
-
380
- _invariant(typeof spec !== 'function', "ReactClass: You're attempting to " + 'use a component class or function as a mixin. Instead, just use a ' + 'regular object.');
381
- _invariant(!ReactElement.isValidElement(spec), "ReactClass: You're attempting to " + 'use a component as a mixin. Instead, just use a regular object.');
382
-
383
- var proto = Constructor.prototype;
384
- var autoBindPairs = proto.__reactAutoBindPairs;
385
-
386
- // By handling mixins before any other properties, we ensure the same
387
- // chaining order is applied to methods with DEFINE_MANY policy, whether
388
- // mixins are listed before or after these methods in the spec.
389
- if (spec.hasOwnProperty(MIXINS_KEY)) {
390
- RESERVED_SPEC_KEYS.mixins(Constructor, spec.mixins);
391
- }
392
-
393
- for (var name in spec) {
394
- if (!spec.hasOwnProperty(name)) {
395
- continue;
396
- }
397
-
398
- if (name === MIXINS_KEY) {
399
- // We have already handled mixins in a special case above.
400
- continue;
401
- }
402
-
403
- var property = spec[name];
404
- var isAlreadyDefined = proto.hasOwnProperty(name);
405
- validateMethodOverride(isAlreadyDefined, name);
406
-
407
- if (RESERVED_SPEC_KEYS.hasOwnProperty(name)) {
408
- RESERVED_SPEC_KEYS[name](Constructor, property);
409
- } else {
410
- // Setup methods on prototype:
411
- // The following member methods should not be automatically bound:
412
- // 1. Expected ReactClass methods (in the "interface").
413
- // 2. Overridden methods (that were mixed in).
414
- var isReactClassMethod = ReactClassInterface.hasOwnProperty(name);
415
- var isFunction = typeof property === 'function';
416
- var shouldAutoBind = isFunction && !isReactClassMethod && !isAlreadyDefined && spec.autobind !== false;
417
-
418
- if (shouldAutoBind) {
419
- autoBindPairs.push(name, property);
420
- proto[name] = property;
421
- } else {
422
- if (isAlreadyDefined) {
423
- var specPolicy = ReactClassInterface[name];
424
-
425
- // These cases should already be caught by validateMethodOverride.
426
- _invariant(isReactClassMethod && (specPolicy === 'DEFINE_MANY_MERGED' || specPolicy === 'DEFINE_MANY'), 'ReactClass: Unexpected spec policy %s for key %s ' + 'when mixing in component specs.', specPolicy, name);
427
-
428
- // For methods which are defined more than once, call the existing
429
- // methods before calling the new property, merging if appropriate.
430
- if (specPolicy === 'DEFINE_MANY_MERGED') {
431
- proto[name] = createMergedResultFunction(proto[name], property);
432
- } else if (specPolicy === 'DEFINE_MANY') {
433
- proto[name] = createChainedFunction(proto[name], property);
434
- }
435
- } else {
436
- proto[name] = property;
437
- if (process.env.NODE_ENV !== 'production') {
438
- // Add verbose displayName to the function, which helps when looking
439
- // at profiling tools.
440
- if (typeof property === 'function' && spec.displayName) {
441
- proto[name].displayName = spec.displayName + '_' + name;
442
- }
443
- }
444
- }
445
- }
446
- }
447
- }
448
- }
449
-
450
- function mixStaticSpecIntoComponent(Constructor, statics) {
451
- if (!statics) {
452
- return;
453
- }
454
- for (var name in statics) {
455
- var property = statics[name];
456
- if (!statics.hasOwnProperty(name)) {
457
- continue;
458
- }
459
-
460
- var isReserved = name in RESERVED_SPEC_KEYS;
461
- _invariant(!isReserved, 'ReactClass: You are attempting to define a reserved ' + 'property, `%s`, that shouldn\'t be on the "statics" key. Define it ' + 'as an instance property instead; it will still be accessible on the ' + 'constructor.', name);
462
-
463
- var isInherited = name in Constructor;
464
- _invariant(!isInherited, 'ReactClass: You are attempting to define ' + '`%s` on your component more than once. This conflict may be ' + 'due to a mixin.', name);
465
- Constructor[name] = property;
466
- }
467
- }
468
-
469
- /**
470
- * Merge two objects, but throw if both contain the same key.
471
- *
472
- * @param {object} one The first object, which is mutated.
473
- * @param {object} two The second object
474
- * @return {object} one after it has been mutated to contain everything in two.
475
- */
476
- function mergeIntoWithNoDuplicateKeys(one, two) {
477
- _invariant(one && two && typeof one === 'object' && typeof two === 'object', 'mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.');
478
-
479
- for (var key in two) {
480
- if (two.hasOwnProperty(key)) {
481
- _invariant(one[key] === undefined, 'mergeIntoWithNoDuplicateKeys(): ' + 'Tried to merge two objects with the same key: `%s`. This conflict ' + 'may be due to a mixin; in particular, this may be caused by two ' + 'getInitialState() or getDefaultProps() methods returning objects ' + 'with clashing keys.', key);
482
- one[key] = two[key];
483
- }
484
- }
485
- return one;
486
- }
487
-
488
- /**
489
- * Creates a function that invokes two functions and merges their return values.
490
- *
491
- * @param {function} one Function to invoke first.
492
- * @param {function} two Function to invoke second.
493
- * @return {function} Function that invokes the two argument functions.
494
- * @private
495
- */
496
- function createMergedResultFunction(one, two) {
497
- return function mergedResult() {
498
- var a = one.apply(this, arguments);
499
- var b = two.apply(this, arguments);
500
- if (a == null) {
501
- return b;
502
- } else if (b == null) {
503
- return a;
504
- }
505
- var c = {};
506
- mergeIntoWithNoDuplicateKeys(c, a);
507
- mergeIntoWithNoDuplicateKeys(c, b);
508
- return c;
509
- };
510
- }
511
-
512
- /**
513
- * Creates a function that invokes two functions and ignores their return vales.
514
- *
515
- * @param {function} one Function to invoke first.
516
- * @param {function} two Function to invoke second.
517
- * @return {function} Function that invokes the two argument functions.
518
- * @private
519
- */
520
- function createChainedFunction(one, two) {
521
- return function chainedFunction() {
522
- one.apply(this, arguments);
523
- two.apply(this, arguments);
524
- };
525
- }
526
-
527
- /**
528
- * Binds a method to the component.
529
- *
530
- * @param {object} component Component whose method is going to be bound.
531
- * @param {function} method Method to be bound.
532
- * @return {function} The bound method.
533
- */
534
- function bindAutoBindMethod(component, method) {
535
- var boundMethod = method.bind(component);
536
- if (process.env.NODE_ENV !== 'production') {
537
- boundMethod.__reactBoundContext = component;
538
- boundMethod.__reactBoundMethod = method;
539
- boundMethod.__reactBoundArguments = null;
540
- var componentName = component.constructor.displayName;
541
- var _bind = boundMethod.bind;
542
- boundMethod.bind = function (newThis) {
543
- for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
544
- args[_key - 1] = arguments[_key];
545
- }
546
-
547
- // User is trying to bind() an autobound method; we effectively will
548
- // ignore the value of "this" that the user is trying to use, so
549
- // let's warn.
550
- if (newThis !== component && newThis !== null) {
551
- process.env.NODE_ENV !== 'production' ? warning(false, 'bind(): React component methods may only be bound to the ' + 'component instance. See %s', componentName) : void 0;
552
- } else if (!args.length) {
553
- process.env.NODE_ENV !== 'production' ? warning(false, 'bind(): You are binding a component method to the component. ' + 'React does this for you automatically in a high-performance ' + 'way, so you can safely remove this call. See %s', componentName) : void 0;
554
- return boundMethod;
555
- }
556
- var reboundMethod = _bind.apply(boundMethod, arguments);
557
- reboundMethod.__reactBoundContext = component;
558
- reboundMethod.__reactBoundMethod = method;
559
- reboundMethod.__reactBoundArguments = args;
560
- return reboundMethod;
561
- };
562
- }
563
- return boundMethod;
564
- }
565
-
566
- /**
567
- * Binds all auto-bound methods in a component.
568
- *
569
- * @param {object} component Component whose method is going to be bound.
570
- */
571
- function bindAutoBindMethods(component) {
572
- var pairs = component.__reactAutoBindPairs;
573
- for (var i = 0; i < pairs.length; i += 2) {
574
- var autoBindKey = pairs[i];
575
- var method = pairs[i + 1];
576
- component[autoBindKey] = bindAutoBindMethod(component, method);
577
- }
578
- }
579
-
580
- var IsMountedMixin = {
581
- componentDidMount: function () {
582
- this.__isMounted = true;
583
- },
584
- componentWillUnmount: function () {
585
- this.__isMounted = false;
586
- }
587
- };
588
-
589
- /**
590
- * Add more to the ReactClass base class. These are all legacy features and
591
- * therefore not already part of the modern ReactComponent.
592
- */
593
- var ReactClassMixin = {
594
- /**
595
- * TODO: This will be deprecated because state should always keep a consistent
596
- * type signature and the only use case for this, is to avoid that.
597
- */
598
- replaceState: function (newState, callback) {
599
- this.updater.enqueueReplaceState(this, newState, callback);
600
- },
601
-
602
- /**
603
- * Checks whether or not this composite component is mounted.
604
- * @return {boolean} True if mounted, false otherwise.
605
- * @protected
606
- * @final
607
- */
608
- isMounted: function () {
609
- if (process.env.NODE_ENV !== 'production') {
610
- process.env.NODE_ENV !== 'production' ? warning(this.__didWarnIsMounted, '%s: isMounted is deprecated. Instead, make sure to clean up ' + 'subscriptions and pending requests in componentWillUnmount to ' + 'prevent memory leaks.', this.constructor && this.constructor.displayName || this.name || 'Component') : void 0;
611
- this.__didWarnIsMounted = true;
612
- }
613
- return !!this.__isMounted;
614
- }
615
- };
616
-
617
- var ReactClassComponent = function () {};
618
- _assign(ReactClassComponent.prototype, ReactComponent.prototype, ReactClassMixin);
619
-
620
- /**
621
- * Creates a composite component class given a class specification.
622
- * See https://facebook.github.io/react/docs/top-level-api.html#react.createclass
623
- *
624
- * @param {object} spec Class specification (which must define `render`).
625
- * @return {function} Component constructor function.
626
- * @public
627
- */
628
- function createClass(spec) {
629
- // To keep our warnings more understandable, we'll use a little hack here to
630
- // ensure that Constructor.name !== 'Constructor'. This makes sure we don't
631
- // unnecessarily identify a class without displayName as 'Constructor'.
632
- var Constructor = identity(function (props, context, updater) {
633
- // This constructor gets overridden by mocks. The argument is used
634
- // by mocks to assert on what gets mounted.
635
-
636
- if (process.env.NODE_ENV !== 'production') {
637
- process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly. Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : void 0;
638
- }
639
-
640
- // Wire up auto-binding
641
- if (this.__reactAutoBindPairs.length) {
642
- bindAutoBindMethods(this);
643
- }
644
-
645
- this.props = props;
646
- this.context = context;
647
- this.refs = emptyObject;
648
- this.updater = updater || ReactNoopUpdateQueue;
649
-
650
- this.state = null;
651
-
652
- // ReactClasses doesn't have constructors. Instead, they use the
653
- // getInitialState and componentWillMount methods for initialization.
654
-
655
- var initialState = this.getInitialState ? this.getInitialState() : null;
656
- if (process.env.NODE_ENV !== 'production') {
657
- // We allow auto-mocks to proceed as if they're returning null.
658
- if (initialState === undefined && this.getInitialState._isMockFunction) {
659
- // This is probably bad practice. Consider warning here and
660
- // deprecating this convenience.
661
- initialState = null;
662
- }
663
- }
664
- _invariant(typeof initialState === 'object' && !Array.isArray(initialState), '%s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent');
665
-
666
- this.state = initialState;
667
- });
668
- Constructor.prototype = new ReactClassComponent();
669
- Constructor.prototype.constructor = Constructor;
670
- Constructor.prototype.__reactAutoBindPairs = [];
671
-
672
- injectedMixins.forEach(mixSpecIntoComponent.bind(null, Constructor));
673
-
674
- mixSpecIntoComponent(Constructor, IsMountedMixin);
675
- mixSpecIntoComponent(Constructor, spec);
676
-
677
- // Initialize the defaultProps property after all mixins have been merged.
678
- if (Constructor.getDefaultProps) {
679
- Constructor.defaultProps = Constructor.getDefaultProps();
680
- }
681
-
682
- if (process.env.NODE_ENV !== 'production') {
683
- // This is a tag to indicate that the use of these method names is ok,
684
- // since it's used with createClass. If it's not, then it's likely a
685
- // mistake so we'll warn you to use the static property, property
686
- // initializer or constructor respectively.
687
- if (Constructor.getDefaultProps) {
688
- Constructor.getDefaultProps.isReactClassApproved = {};
689
- }
690
- if (Constructor.prototype.getInitialState) {
691
- Constructor.prototype.getInitialState.isReactClassApproved = {};
692
- }
693
- }
694
-
695
- _invariant(Constructor.prototype.render, 'createClass(...): Class specification must implement a `render` method.');
696
-
697
- if (process.env.NODE_ENV !== 'production') {
698
- process.env.NODE_ENV !== 'production' ? warning(!Constructor.prototype.componentShouldUpdate, '%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', spec.displayName || 'A component') : void 0;
699
- process.env.NODE_ENV !== 'production' ? warning(!Constructor.prototype.componentWillRecieveProps, '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', spec.displayName || 'A component') : void 0;
700
- }
701
-
702
- // Reduce time spent doing lookups by setting these on the prototype.
703
- for (var methodName in ReactClassInterface) {
704
- if (!Constructor.prototype[methodName]) {
705
- Constructor.prototype[methodName] = null;
706
- }
707
- }
708
-
709
- return Constructor;
710
- }
711
-
712
- module.exports = createClass;