Skip to content

Commit

Permalink
Removed some gratuitous destructuring
Browse files Browse the repository at this point in the history
  • Loading branch information
bvaughn committed Aug 7, 2017
1 parent 302cda2 commit 031fa4f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 34 deletions.
6 changes: 2 additions & 4 deletions js/repl/src/CodeMirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,11 @@ export default class CodeMirror extends React.Component {
}

render() {
const { autoFocus, value } = this.props;

return (
<textarea
autoComplete="off"
autoFocus={autoFocus}
defaultValue={value}
autoFocus={this.props.autoFocus}
defaultValue={this.props.value}
ref={this._setTextAreaRef}
/>
);
Expand Down
47 changes: 17 additions & 30 deletions js/repl/src/Repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,44 +74,35 @@ export default class Repl extends React.Component {
}

render() {
const {
code,
compiled,
compileError,
evaluate,
evalError,
lineWrap,
plugins,
presets
} = this.state;
const state = this.state;

const options = {
lineWrapping: lineWrap
lineWrapping: state.lineWrap
};

return (
<div className={styles.repl}>
<ReplOptions
className={styles.optionsColumn}
evaluate={evaluate}
lineWrap={lineWrap}
pluginState={plugins}
presetState={presets}
evaluate={state.evaluate}
lineWrap={state.lineWrap}
pluginState={state.plugins}
presetState={state.presets}
toggleSetting={this._toggleSetting}
/>

<div className={styles.panels}>
<CodeMirrorPanel
className={styles.codeMirrorPanel}
code={code}
error={compileError}
code={state.code}
error={state.compileError}
onChange={this._updateCode}
options={options}
/>
<CodeMirrorPanel
className={styles.codeMirrorPanel}
code={compiled}
error={evalError}
code={state.compiled}
error={state.evalError}
options={options}
/>
</div>
Expand Down Expand Up @@ -150,12 +141,10 @@ export default class Repl extends React.Component {
}

_compile = (code: string, state: State) => {
const { evaluate, plugins } = state;

return compile(code, {
evaluate: evaluate,
evaluate: state.evaluate,
presets: this._presetsToArray(state),
prettify: plugins.prettier.isEnabled
prettify: state.plugins.prettier.isEnabled
});
};

Expand Down Expand Up @@ -213,10 +202,8 @@ export default class Repl extends React.Component {
}
},
() => {
const { code } = this.state;

this._checkForUnloadedPlugins();
this._updateCode(code);
this._updateCode(this.state.code);
}
);
};
Expand All @@ -226,7 +213,7 @@ export default class Repl extends React.Component {
};

_persistState = () => {
const { code, evaluate, lineWrap, plugins } = this.state;
const plugins = this.state.plugins;

const presetsArray = this._presetsToArray();

Expand All @@ -240,10 +227,10 @@ export default class Repl extends React.Component {
babili: plugins['babili-standalone'].isEnabled,
browsers: '', // TODO
builtIns: false, // TODO
code,
code: this.state.code,
debug: false, // TODO
evaluate,
lineWrap,
evaluate: this.state.evaluate,
lineWrap: this.state.lineWrap,
presets: presetsArray.join(','),
prettier: plugins.prettier.isEnabled,
targets: '' // TODO
Expand Down

0 comments on commit 031fa4f

Please sign in to comment.