fix: React hooks - variable declaration order and lazy initialization (#1017)

- Fixed variable declaration order in CLIToolsPageClient.js (functions before useEffect)
- Added lazy initialization for useState in BasicChatPageClient.js to read from localStorage
- Reduced ESLint errors by ~23%

Co-authored-by: yuangejiaozhu <leegajone@email.com>
This commit is contained in:
Jone
2026-05-12 09:25:29 +07:00
committed by GitHub
co-authored by yuangejiaozhu
parent 17cab0ed52
commit c90cb8ebda
2 changed files with 30 additions and 25 deletions
@@ -24,13 +24,6 @@ export default function CLIToolsPageClient({ machineId }) {
const [apiKeys, setApiKeys] = useState([]);
const [toolStatuses, setToolStatuses] = useState({});
useEffect(() => {
fetchConnections();
loadCloudSettings();
fetchApiKeys();
fetchAllStatuses();
}, []);
const fetchAllStatuses = async () => {
try {
const res = await fetch(ALL_STATUSES_URL);
@@ -88,6 +81,13 @@ export default function CLIToolsPageClient({ machineId }) {
}
};
useEffect(() => {
fetchConnections();
loadCloudSettings();
fetchApiKeys();
fetchAllStatuses();
}, []);
const getActiveProviders = () => connections.filter(c => c.isActive !== false);
const getAllAvailableModels = () => {