Fix for editor selection issue

This commit is contained in:
Mustafa Buyukcelebi 2019-12-02 17:39:49 +03:00
parent f945378466
commit 67ebe8fbd2
3 changed files with 8 additions and 11 deletions

View File

@ -1,4 +0,0 @@
module.exports = {
root: true,
extends: '@react-native-community',
};

View File

@ -7,7 +7,8 @@
"plugin:eslint-comments/recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:jest/recommended"
"plugin:jest/recommended",
"@react-native-community"
],
"env": {
"browser": true,
@ -46,7 +47,7 @@
"no-case-declarations": "off",
"no-cycle": "off",
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
"react-hooks/exhaustive-deps": "off",
"import/no-extraneous-dependencies": [
"error",
{

View File

@ -45,13 +45,13 @@ const MarkdownEditorView = ({
if (!isPreviewActive) {
_setTextAndSelection({ selection: { start: 0, end: 0 }, text });
}
}, [_setTextAndSelection, isPreviewActive, text]);
}, [isPreviewActive]);
useEffect(() => {
if (text === '' && draftBody !== '') {
_setTextAndSelection({ selection: { start: 0, end: 0 }, text: draftBody });
}
}, [_setTextAndSelection, draftBody, text]);
}, [draftBody]);
useEffect(() => {
if (editable === null) {
@ -63,7 +63,7 @@ const MarkdownEditorView = ({
} else {
setEditable(!isLoading);
}
}, [editable, isLoading]);
}, [isLoading]);
useEffect(() => {
if (uploadedImage && uploadedImage.url) {
@ -75,7 +75,7 @@ const MarkdownEditorView = ({
isImage: !!uploadedImage,
});
}
}, [_setTextAndSelection, selection, text, uploadedImage]);
}, [uploadedImage]);
useEffect(() => {
setText(draftBody);
@ -91,7 +91,7 @@ const MarkdownEditorView = ({
handleIsFormValid(text);
}
}
}, [_changeText, handleIsFormValid, text]);
}, [text]);
// eslint-disable-next-line react-hooks/exhaustive-deps
const _changeText = useCallback(input => {