-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathcomponent.js
26 lines (19 loc) · 893 Bytes
/
component.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
'use strict';
var React = require('react');
var Component = React.Component;
var transformComponentStatic = require('./util/transformComponentStatic');
var transformComponentDynamic = require('./util/transformComponentDynamic');
exports.addon = function (renderer) {
if (process.env.NODE_ENV !== 'production') {
require('./__dev__/warnOnMissingDependencies')('component', renderer, ['rule', 'cache']);
}
function CssComponent (props, context) {
Component.call(this, props, context);
var Comp = this.constructor;
if (Comp.css) transformComponentStatic(renderer, Comp.prototype, Comp.css);
if (this.css) transformComponentDynamic(renderer, Comp, this.css.bind(this));
}
CssComponent.prototype = Object.create(Component.prototype);
CssComponent.prototype.constructor = CssComponent;
renderer.Component = CssComponent;
};