diff --git a/webapp/src/components/markdownEditorInput/markdownEditorInput.tsx b/webapp/src/components/markdownEditorInput/markdownEditorInput.tsx index 85a60c573..f93a2aefa 100644 --- a/webapp/src/components/markdownEditorInput/markdownEditorInput.tsx +++ b/webapp/src/components/markdownEditorInput/markdownEditorInput.tsx @@ -47,13 +47,12 @@ const MarkdownEditorInput = (props: Props): ReactElement => { , [workspaceUsers]) const ref = useRef(null) - const generateEditorState = (text?: string) => { - const state = EditorState.createWithContent(ContentState.createFromText(text || '')) - return EditorState.moveSelectionToEnd(state) + const generateEditorState = (text?: string): EditorState => { + return EditorState.createWithContent(ContentState.createFromText(text || '')) } const [editorState, setEditorState] = useState(() => { - return generateEditorState(initialText) + return EditorState.moveSelectionToEnd(generateEditorState(initialText)) }) // avoiding stale closure