Merge pull request #1347 from esteemapp/bugfix/editor-selection

Bugfix/editor selection
This commit is contained in:
Feruz M 2019-12-03 04:40:49 +02:00 committed by GitHub
commit 11ca8e3185
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:eslint-comments/recommended",
"plugin:import/errors", "plugin:import/errors",
"plugin:import/warnings", "plugin:import/warnings",
"plugin:jest/recommended" "plugin:jest/recommended",
"@react-native-community"
], ],
"env": { "env": {
"browser": true, "browser": true,
@ -46,7 +47,7 @@
"no-case-declarations": "off", "no-case-declarations": "off",
"no-cycle": "off", "no-cycle": "off",
"react-hooks/rules-of-hooks": "error", "react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn", "react-hooks/exhaustive-deps": "off",
"import/no-extraneous-dependencies": [ "import/no-extraneous-dependencies": [
"error", "error",
{ {

View File

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