We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi, thanks for your little gem. I was able to simplify my code from
export default function InvoicesDashboard() { const [isLoading, setIsLoading] = useState(false); const [invoices, setInvoices] = useState([]); useEffect(() => { setIsLoading(true); api.get(`/invoices`) .then((data) => setInvoices(data)) .finally(() => setIsLoading(false)) }, []); // component rendering return <InvoicesTable invoices={invoices}/> }
to this
export default function InvoicesDashboard() { const [{data: invoices, loading}] = useApi('/invoices'); return <InvoicesTable invoices={invoices || []}/>; }
However I need to manually handle first render when data are not already loaded with invoices || [].
invoices || []
I was wondering if there's any way to specify a initial value for data as in useState hook. If not it would be a great addition to this project.
useState
Thanks.
The text was updated successfully, but these errors were encountered:
This is not supported and will probably not be, considering how easy handling this case in user code is. See previous discussion in #110 and #26
Sorry, something went wrong.
Thanks, I missed those ones. I solved with
const [{data: invoices = [], loading}] = useApi('/invoices');
No branches or pull requests
Hi, thanks for your little gem. I was able to simplify my code from
to this
However I need to manually handle first render when data are not already loaded with
invoices || []
.I was wondering if there's any way to specify a initial value for data as in
useState
hook. If not it would be a great addition to this project.Thanks.
The text was updated successfully, but these errors were encountered: