-
Notifications
You must be signed in to change notification settings - Fork 11
/
index.js
62 lines (48 loc) · 1.78 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* jshint node:true */
'use strict';
var invariant = require('react/lib/invariant'),
React = React || require('react'),
reactInternal = require('./third_party/react-internal'),
mixSpecIntoComponent = reactInternal.mixSpecIntoComponent,
ReactCompositeComponentInterface = reactInternal.ReactCompositeComponentInterface,
bindMethod = reactInternal.bindMethod;
function ReactComponentBase() {
this.construct.apply(this, arguments);
}
ReactComponentBase.applyMixins = function applyMixins(mixins) {
mixins = Array.prototype.slice.call(arguments);
invariant(
mixins && mixins.length > 0,
'You should provide at least one mixin'
);
for (var i = 0; i < mixins.length; i++) {
mixSpecIntoComponent(this, mixins[i]);
}
};
ReactComponentBase.prototype = React.createClass( { render: function () {} }).componentConstructor.prototype;
if ("production" !== process.env.NODE_ENV) {
//debug membrne is really not compatible with our way of doing things
ReactComponentBase.prototype = Object.getPrototypeOf(ReactComponentBase.prototype);
}
delete ReactComponentBase.prototype.render;
exports.ReactComponentBase = ReactComponentBase;
function autoBindMethods(constructor) {
var proto = constructor.prototype,
name;
for (name in proto) {
if (proto.hasOwnProperty(name)) {
var property = proto[name],
isCompositeComponentMethod = name in ReactCompositeComponentInterface,
markedDontBind = property && property.__reactDontBind,
isFunction = typeof property === 'function',
shouldAutoBind =
isFunction &&
!isCompositeComponentMethod &&
!markedDontBind;
if (shouldAutoBind) {
bindMethod(proto, name, property);
}
}
}
}
exports.autoBindMethods = autoBindMethods;