Error code
import {useState,useEffect} from 'react'
const useData = () => {
const [data,setData] = useState({count:0});
useEffect(()=>{
setTimeout(()=> {
setData((data)=>({...data,count:data.count+1}))
}, 1000 );
},[])
return {data}
}
export default useData
Modified code
import React from 'react'
import useData from '../hooks/AppData'
const AppData = ()=>{
const {data} = useData()
return <div>
count->{data.count}
</div>
}
export default AppData; // Change the first letter of the name to uppercase