Merge pull request 'update usages of 'useAsync' to reflect current version of API' (#1) from kaioken-docs-patch-1 into master

Reviewed-on: LankyMoose/docs.sheetjs.com#1
This commit is contained in:
LankyMoose 2024-07-16 02:20:57 +00:00
commit 6f54b38efe

@ -224,7 +224,7 @@ import { read, utils } from 'xlsx';
/* Fetch and parse the file */
// highlight-next-line
const [ pres, loading, error ] = useAsync<President[]>(async() => {
const { data: pres, loading, error } = useAsync<President[]>(async() => {
/* Download from https://docs.sheetjs.com/pres.numbers */
const f = await fetch("https://docs.sheetjs.com/pres.numbers");
const ab = await f.arrayBuffer();
@ -331,7 +331,7 @@ interface President {
export default function SheetJSKaiokenAoO() {
/* Fetch and parse the file */
const [ pres, loading, error ] = useAsync<President[]>(async() => {
const { data: pres, loading, error } = useAsync<President[]>(async() => {
const f = await (await fetch("https://docs.sheetjs.com/pres.xlsx")).arrayBuffer();
const wb = read(f); // parse the array buffer
const ws = wb.Sheets[wb.SheetNames[0]]; // get the first worksheet
@ -371,10 +371,10 @@ export default function SheetJSKaiokenAoO() {
Typically the JSX structure uses ternary expressions for testing status:
```jsx
const [ pres, loading, error ] = useAsync(async() => { /* ... */ });
const { data, loading, error } = useAsync(async() => { /* ... */ });
return ( <>
{ pres ? (
{ data ? (
<b>Data is loaded</b>
) : loading ? (
<b>Loading ...</b>