This is the error I get : TypeError: observer.getOptimisticResult is not a function
I'm trying to work with React-Query and Supabase to read data into a React-Table. I've created a useReadData.ts
hook as shown below:
export default function useReadData(table_name, startRow, endRow) {
return useQuery(
["read_data"],
() =>
supabase
.from(table_name)
.select("*")
.range(startRow, endRow)
.then(handleSupabaseError)
.then(({ data }) => data)
);
}
I have called this hook in my index.tsx
file within the App()
component:
function App() {
const [rowData, setRowData] = React.useState([]);
const [loading, setLoading] = React.useState(false);
const [pageCount, setPageCount] = React.useState(0);
const fetchIdRef = React.useRef(0);
const fetchData = React.useCallback(({ pageSize, pageIndex }) => {
if (fetchId === fetchIdRef.current) {
const startRow = pageSize * pageIndex;
const endRow = startRow + pageSize;
const table_name = "company";
const data = () => useReadData(table_name, startRow, endRow);
console.log(data);
setRowData(data);
setPageCount(10);
setLoading(false);
}
}, []);
I've spent weeks, but I'm not able to resolve this error. Please help!