useFetchData

This hook uses only the data handler of the data object to load data without updating the data object state. This can be useful if you want to make a lookup use the same data object that is used to render data.

Example

import { useFetchData } from "@olenbetong/appframe-react";

function MyComponent({ domain, editedRecord }) {
let { loading, refresh, refreshRows, data } = useFetchData(
dsMyDataObject,
domain ? `[Domain] = '${domain}'` : false,
);

return (
<>
{loading && <CircularProgress />}
<Button onClick={refresh}>Update select options</Button>
<select>
{data.map((record) => (
<option key={record.PrimKey} value={record.CustomerID}>
{record.CustomerName}
</option>
))}
</select>
<Button onClick={() => refreshRows(`[PrimKey] = '${editedRecord.PrimKey}'`)}>
Refresh edited record
</Button>
</>
);
}

API

Last updated

Was this helpful?