fix: resolve ReferenceError accessing scanModels before initialization
Moved the useEffect that auto-scans models below the definition of scanModels to fix a ReferenceError caused by the Temporal Dead Zone (TDZ) when calling a block-scoped useCallback function before it was initialized.
This commit is contained in:
1 parent
36b80bc0a8
commit
2144a92349
1 file changed
+8
-8
@@ -193,14 +193,6 @@ export function useRuntimeManager() {
|
||||
};
|
||||
}, [refresh]);
|
||||
|
||||
// Auto-scan models when the configured directory changes
|
||||
useEffect(() => {
|
||||
const modelsDir = draftState.liveSnapshot.config.models_dir;
|
||||
if (modelsDir) {
|
||||
scanModels(modelsDir).catch(() => undefined);
|
||||
}
|
||||
}, [draftState.liveSnapshot.config.models_dir, scanModels]);
|
||||
|
||||
const openDraft = useCallback(() => {
|
||||
setDraftState((current) => {
|
||||
const draftConfig = current.isDirty ? current.draftConfig : cloneConfig(current.savedBaseline);
|
||||
@@ -381,6 +373,14 @@ export function useRuntimeManager() {
|
||||
}
|
||||
}, []);
|
||||
|
||||
// Auto-scan models when the configured directory changes
|
||||
useEffect(() => {
|
||||
const modelsDir = draftState.liveSnapshot.config.models_dir;
|
||||
if (modelsDir) {
|
||||
scanModels(modelsDir).catch(() => undefined);
|
||||
}
|
||||
}, [draftState.liveSnapshot.config.models_dir, scanModels]);
|
||||
|
||||
const commitSavedSnapshot = useCallback((next: RuntimeSnapshot, keepOpen: boolean) => {
|
||||
setDraftState((current) => ({
|
||||
...current,
|
||||
|
||||
Reference in new issue
Block a user