config: add plugins hook and decoration

This commit is contained in:
Guillermo Rauch 2016-07-07 17:15:42 -07:00
parent c97b67b4c8
commit eb147d9b9a

View file

@ -20,17 +20,20 @@ export default class Config extends React.Component {
componentDidMount () {
ipcRenderer.on('config change', this.onChange);
ipcRenderer.on('plugins change', this.onChange);
}
// passes `config` as props to the decorated component
render () {
const child = React.Children.only(this.props.children);
const { config } = this.state;
return React.cloneElement(child, { config });
const decorate = remote.require('./plugins').decorateConfig;
return React.cloneElement(child, { config: decorate(config) });
}
componentWillUnmount () {
ipcRenderer.removeListener('config change', this.onChange);
ipcRenderer.removeListener('plugins change', this.onChange);
}
}