Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fixed infinite flicker #553

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/playground/App.js
Expand Up @@ -133,7 +133,6 @@
initialOptions = fillOptionsDefaults(initialOptions);

const [text, setText] = useState(initialText);
const [fix, setFix] = useState(false);
const [options, setOptions] = useState(initialOptions);

// In some cases, Linter modifies `languageOptions`, so we'll deep-clone them
Expand All @@ -152,7 +151,7 @@

const lint = () => {
try {
const { messages, output } = linter.verifyAndFix(text, optionsForLinter, { fix });
const { messages, output } = linter.verifyAndFix(text, optionsForLinter, { fix: false });
let fatalMessage;

if (messages && messages.length > 0 && messages[0].fatal) {
Expand Down Expand Up @@ -192,7 +191,7 @@

url.hash = Unicode.encodeToBase64(serializedState);
history.replaceState(null, null, url);
}, [options, text]);
}, [options]);

Check warning on line 194 in src/playground/App.js

View workflow job for this annotation

GitHub Actions / Lint

React Hook useCallback has a missing dependency: 'text'. Either include it or remove the dependency array

const { messages, output, fatalMessage, crashError, validationError } = lint();
const lintTime = Date.now();
Expand Down Expand Up @@ -228,7 +227,6 @@
}, []);

const debouncedOnUpdate = useMemo(() => debounce(value => {
setFix(false);
setText(value);
storeState({ newText: value });
}, 400), [storeState]);
Expand Down