revert(island): ⏪ c6eb4383
This commit is contained in:
parent
c6eb438314
commit
72b0794c61
|
@ -54,8 +54,9 @@ export default function CardList<ApiResponse, RefType = null>(
|
||||||
loader={placeholder({ ref: index === 0 ? ref : undefined })}
|
loader={placeholder({ ref: index === 0 ? ref : undefined })}
|
||||||
fallback={fallback}
|
fallback={fallback}
|
||||||
signal={ac.signal}
|
signal={ac.signal}
|
||||||
value={updateFromList(list, index)}
|
>
|
||||||
/>
|
{updateFromList(list, index)}
|
||||||
|
</Suspense>
|
||||||
))
|
))
|
||||||
return <>{placeholders}</>
|
return <>{placeholders}</>
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,14 +18,13 @@ function RenderError(
|
||||||
|
|
||||||
export type Fallback = ({ error }: { error: Error }) => JSX.Element
|
export type Fallback = ({ error }: { error: Error }) => JSX.Element
|
||||||
|
|
||||||
export type SuspenseProps = {
|
export default function Suspense(
|
||||||
|
{ loader, fallback, signal, children }: {
|
||||||
loader: JSX.Element
|
loader: JSX.Element
|
||||||
fallback?: Fallback
|
fallback?: Fallback
|
||||||
signal?: AbortSignal
|
signal?: AbortSignal
|
||||||
} & ({ children: Promise<JSX.Element> } | { value: Promise<JSX.Element> })
|
children: Promise<JSX.Element>
|
||||||
|
},
|
||||||
export default function Suspense(
|
|
||||||
{ loader, fallback, signal, ...props }: SuspenseProps,
|
|
||||||
) {
|
) {
|
||||||
const displayed = useSignal(loader)
|
const displayed = useSignal(loader)
|
||||||
let loaded = false
|
let loaded = false
|
||||||
|
@ -39,9 +38,7 @@ export default function Suspense(
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
//Prevent transpilation error due to children expected to not be a promise
|
children
|
||||||
const inner = 'value' in props ? props.value : props.children
|
|
||||||
inner
|
|
||||||
.then((element) => {
|
.then((element) => {
|
||||||
if (signal?.aborted) return
|
if (signal?.aborted) return
|
||||||
displayed.value = element
|
displayed.value = element
|
||||||
|
|
Loading…
Reference in a new issue