var React = require('react/addons'); var assign = require('object-assign'); var ipc = require('ipc'); // TODO: move this somewhere else if (localStorage.getItem('options')) { ipc.send('vm', JSON.parse(localStorage.getItem('options')).save_vm_on_quit); } var Preferences = React.createClass({ getInitialState: function () { var data = JSON.parse(localStorage.getItem('options')); return assign({ save_vm_on_quit: true, report_analytics: true }, data || {}); }, handleChange: function (key) { var change = {}; change[key] = !this.state[key]; console.log(change); this.setState(change); }, saveState: function () { ipc.send('vm', this.state.save_vm_on_quit); localStorage.setItem('options', JSON.stringify(this.state)); }, componentDidMount: function () { this.saveState(); }, componentDidUpdate: function () { this.saveState(); }, render: function () { console.log('render'); return (