Slide 35
Slide 35 text
4UZMF%FDPSBUPS
import noop from 'lodash/noop';
import React, { Component, PropTypes } from 'react';
export const withStyleDecorator = (style) => (ComposedComponent) => (
class WithStyle extends Component {
static displayName = `withStyle(${ComposedComponent.displayName})`;
static contextTypes = {
insertCss: PropTypes.func.isRequired,
};
constructor(props, context) {
super(props, context);
this.removeCss = style ? this.context.insertCss(style) : noop;
}
componentWillUnmount = () => {
this.removeCss && setTimeout(this.removeCss, 0);
};
render = () => (
);
}
);
isomorphic-style-loader
͔Βఏڙ͞ΕΔϚϯλʔ