importReactfrom'react';import{useFetch}from'loki-usefetch';constTestComponent=()=>{const[currentPage,setCurrentPage]=useState(1);// Use the useFetch hook with the API URL and current pageconst{ data, isLoading, isError, refetch }=useFetch<DataItem>('https://example-api.com/data',currentPage);// Define the type/interface representing your data iteminterfaceDataItem{
id: number;
name: string;// Add other properties as needed}if(isLoading){return<div>Loading...</div>;}if(isError){return(<div><div>Error: {isError}</div><buttononClick={()=>refetch(currentPage)}>Retry</button></div>);}return(<div>{data&&data.map((item)=><divkey={item.id}>{item.name}</div>)}<buttononClick={()=>setCurrentPage((prevPage)=>prevPage+1)}>Next Page</button><buttononClick={()=>refetch(currentPage)}>Refresh Data</button></div>);};exportdefaultTestComponent;