Loading...
Loading...
Cannot find name 'useState'TypeScript can't find the variable, function, or type you're referencing. It's either not imported, not declared, or out of scope.
Import the function or type from its source module.
// ❌ Missing import
const [count, setCount] = useState(0); // 💥 Cannot find name 'useState'
// ✅ Import from React
import { useState } from 'react';
const [count, setCount] = useState(0);Configure tsconfig.json to include the right type libraries.
// tsconfig.json
{
"compilerOptions": {
// For browser projects (window, document, etc.)
"lib": ["ES2022", "DOM", "DOM.Iterable"],
// For Node.js projects
// npm install --save-dev @types/node
"types": ["node"]
}
}