Skip to content

Commit 3f57ceb

Browse files
committed
replace ternery with lookup object
1 parent 0452729 commit 3f57ceb

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

ui/frontend/editor/Editor.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@ class SimpleEditor extends React.PureComponent<CommonEditorProps> {
108108
}
109109
}
110110

111+
const editorMap = {
112+
[EditorType.Simple]: SimpleEditor,
113+
[EditorType.Ace]: AceEditor,
114+
[EditorType.Monaco]: MonacoEditor,
115+
};
116+
111117
const Editor: React.SFC = () => {
112118
const code = useSelector((state: State) => state.code);
113119
const editor = useSelector((state: State) => state.configuration.editor);
@@ -119,7 +125,7 @@ const Editor: React.SFC = () => {
119125
const execute = useCallback(() => dispatch(actions.performPrimaryAction()), [dispatch]);
120126
const onEditCode = useCallback((c) => dispatch(actions.editCode(c)), [dispatch]);
121127

122-
const SelectedEditor = editor === EditorType.Simple ? SimpleEditor : editor === EditorType.Monaco ? MonacoEditor : AceEditor;
128+
const SelectedEditor = editorMap[editor];
123129

124130
return (
125131
<div className={styles.container}>

0 commit comments

Comments
 (0)