fix comments being set backwards (#2076)

This commit is contained in:
Scott Bishel 2022-01-10 09:46:47 -07:00 committed by GitHub
parent e6b286f056
commit 33407e7dd9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -47,13 +47,12 @@ const MarkdownEditorInput = (props: Props): ReactElement => {
, [workspaceUsers])
const ref = useRef<Editor>(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