I am trying to use React useState hook in my functional component but I am getting this error:
Failed to compile
./src/Person/Person.js
Line 5:43: React Hook "useState" is called in function "person" which is neither a React function component or a custom React Hook function react-hooks/rules-of-hooks
Search for the keywords to learn more about each error.
This error occurred during the build time and cannot be dismissed.
Here is the code for the same:
import React, {useState} from 'react';
import { tsPropertySignature, directive } from '@babel/types';
const person =props =>{
const [initState,stateChangeFunction]=useState({name:'akie@123'})
return <p>I am from the {}</p>
}
export default person;
Thanks in advance.