From 3b20f98fdcaafff1893266594354445e9345f49e Mon Sep 17 00:00:00 2001 From: Paul Farault Date: Tue, 11 Apr 2023 16:26:41 +0200 Subject: [PATCH] refactor: remove intermediate component --- .../ServiceVariables/Editor/index.tsx | 31 +++++-------------- 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/src/components/Services/ServiceVariables/Editor/index.tsx b/src/components/Services/ServiceVariables/Editor/index.tsx index 60db9c6..9364da9 100644 --- a/src/components/Services/ServiceVariables/Editor/index.tsx +++ b/src/components/Services/ServiceVariables/Editor/index.tsx @@ -6,23 +6,6 @@ import VisualEditor from './VisualEditor' import Toolbar from './Toolbar' import { FormValues } from '../types' -//TODO: use a spread operator to pass props to the editor -const EditorUncontrolled = ({ - isRawEditorMode, - value, - onChange, -}: { - isRawEditorMode: boolean - value: Object - onChange: (newVariables: Object) => void -}) => { - return isRawEditorMode ? ( - - ) : ( - - ) -} - const EditorControlled = ({ control, defaultValues, @@ -37,13 +20,13 @@ const EditorControlled = ({ name="variables" control={control} defaultValue={defaultValues} - render={({ field: { value, onChange } }) => ( - - )} + render={({ field: { value, onChange } }) => + isRawEditorMode ? ( + + ) : ( + + ) + } /> ) }