Get rid of useCallbacks to fix potential issues
This commit is contained in:
parent
f859a2016d
commit
5f77d0e5ee
1 changed files with 6 additions and 6 deletions
12
src/App.tsx
12
src/App.tsx
|
@ -189,7 +189,7 @@ function App() {
|
|||
});
|
||||
}
|
||||
|
||||
const setText = useCallback((newText: string) => {
|
||||
function setText(newText: string) {
|
||||
const model = editor?.getModel();
|
||||
if (!model || !editor) return;
|
||||
model.pushEditOperations(
|
||||
|
@ -203,7 +203,7 @@ function App() {
|
|||
() => null
|
||||
);
|
||||
editor.setPosition({ column: 0, lineNumber: 0});
|
||||
}, [editor]);
|
||||
};
|
||||
|
||||
function handleLoadSample() {
|
||||
setText(rustpadRaw);
|
||||
|
@ -212,14 +212,14 @@ function App() {
|
|||
}
|
||||
}
|
||||
|
||||
const handleUploadFile = useCallback(async (file: File) => {
|
||||
async function handleUploadFile(file: File) {
|
||||
const text = await file.text();
|
||||
setText(text);
|
||||
const newLanguage = getLanguage(file.name);
|
||||
if (newLanguage !== language) handleChangeLanguage(newLanguage);
|
||||
}, [language]);
|
||||
};
|
||||
|
||||
const handleDownloadFile = useCallback(() => {
|
||||
function handleDownloadFile() {
|
||||
const model = editor?.getModel();
|
||||
if (!model || !editor) return;
|
||||
const text = model.getValue();
|
||||
|
@ -229,7 +229,7 @@ function App() {
|
|||
const url = URL.createObjectURL(file);
|
||||
downloadUri(url, fileName);
|
||||
URL.revokeObjectURL(url);
|
||||
}, [editor, language]);
|
||||
};
|
||||
|
||||
useKeyboardCtrlIntercept('s', handleDownloadFile);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue