Files
web-page/src/pages/stock/screener/hooks/useScreenerMode.js
gahusb 4b64761800 fix(screener): silence ESLint no-empty / no-undef in canvas helpers
빈 catch 블록 3곳에 의도 주석 추가, test-setup.js 의 beforeEach
명시적 import. 우리 신규 코드의 lint error 0으로 정리.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-13 21:56:42 +09:00

26 lines
590 B
JavaScript

import { useState } from 'react';
const STORAGE_KEY = 'screener-mode-v1';
const VALID_MODES = new Set(['form', 'canvas']);
function readMode() {
try {
const v = localStorage.getItem(STORAGE_KEY);
return VALID_MODES.has(v) ? v : 'form';
} catch {
return 'form';
}
}
export function useScreenerMode() {
const [mode, setModeState] = useState(readMode);
const setMode = (m) => {
if (!VALID_MODES.has(m)) return;
setModeState(m);
try { localStorage.setItem(STORAGE_KEY, m); } catch { /* ignore quota/security errors */ }
};
return { mode, setMode };
}