hi im useing typescript in to react and now use useState hook but have an error
my code :
import React , { useState } from "react";
interface userData {
name: string;
}
export default function atbComponent() {
let [data, setData] = useState<userData>({
name: 'abolfazl',
});
return (
<>
<span>Hi..{data.name}</span>
</>
)
}
error :
ERROR
[eslint]
src\components\text.tsx
Line 10:27: React Hook "useState" is called in function "atbComponent" that is neither a React function component nor a custom React Hook function. React component names must start with an uppercase letter. React Hook names must start with the word "use" react-hooks/rules-of-hooks
Search for the keywords to learn more about each error.
after use :
// eslint-disable-next-line react-hooks/rules-of-hooks
let [data, setData] = useState<userData>({
name: 'abolfazl',
});
But I want to know what the problem is