Use Destructuring

This commit is contained in:
Christopher Serr
2018-01-22 01:35:44 +01:00
parent 730136643d
commit 2cc3e2945e
2 changed files with 23 additions and 23 deletions
+18 -18
View File
@@ -99,24 +99,24 @@ export class LiveSplit extends React.Component<{}, State> {
}
public render() {
const { route, content } = ((): { route: Route, content: JSX.Element } => {
const [route, content] = ((): [Route, JSX.Element] => {
if (this.state.runEditor) {
return {
route: "run-editor",
content: <RunEditorComponent editor={this.state.runEditor} />,
};
return [
"run-editor",
<RunEditorComponent editor={this.state.runEditor} />,
];
} else if (this.state.layoutEditor) {
return {
route: "layout-editor",
content: <LayoutEditorComponent
return [
"layout-editor",
<LayoutEditorComponent
editor={this.state.layoutEditor}
timer={this.state.timer}
/>,
};
];
} else {
return {
route: "main",
content: <div
return [
"main",
<div
style={{
margin: "10px",
marginBottom: "5px",
@@ -153,7 +153,7 @@ export class LiveSplit extends React.Component<{}, State> {
</div>
</div>
</div>,
};
];
}
})();
@@ -228,12 +228,12 @@ export class LiveSplit extends React.Component<{}, State> {
}
public exportSplits() {
const { lss, name } = this.state.timer.readWith((t) => {
const [lss, name] = this.state.timer.readWith((t) => {
const run = t.getRun();
return {
lss: run.saveAsLss(),
name: run.extendedFileName(true),
};
return [
run.saveAsLss(),
run.extendedFileName(true),
];
});
exportFile(name + ".lss", lss);
}
+5 -5
View File
@@ -179,11 +179,11 @@ export class SideBarContent extends React.Component<Props, State> {
private update() {
if (this.props.route === "main" && this.props.sidebarOpen) {
const { comparison, timingMethod } = this.props.timer.readWith((t) => {
return {
comparison: t.currentComparison(),
timingMethod: t.currentTimingMethod(),
};
const [comparison, timingMethod] = this.props.timer.readWith((t): [string, number] => {
return [
t.currentComparison(),
t.currentTimingMethod(),
];
});
if (comparison !== this.state.comparison || timingMethod !== this.state.timingMethod) {