async-components.jsx — astro Source File
Architecture documentation for async-components.jsx, a javascript file in the astro codebase. 1 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR f055b9af_141a_1d5d_191b_9a6d24e5ebf0["async-components.jsx"] 5458ee59_7908_bf35_f257_ad630e4e60d7["solid-js"] f055b9af_141a_1d5d_191b_9a6d24e5ebf0 --> 5458ee59_7908_bf35_f257_ad630e4e60d7 style f055b9af_141a_1d5d_191b_9a6d24e5ebf0 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { ErrorBoundary, Show, createResource, createSignal, createUniqueId } from 'solid-js';
// It may be good to try short and long sleep times.
// But short is faster for testing.
const SLEEP_MS = 10;
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
export function AsyncComponent(props) {
const id = createUniqueId();
const [data] = createResource(async () => {
// console.log("Start rendering async component " + props.title);
await sleep(props.delay ?? SLEEP_MS);
// console.log("Finish rendering async component " + props.title);
return 'Async result for component id=' + id;
});
const [show, setShow] = createSignal(false);
return (
<div data-name="AsyncComponent" style={{ border: 'black solid 1px', padding: '4px' }}>
{'title=' + (props.title ?? '(none)') + ' '}
{'id=' + id + ' '}
<span>{data()}</span>{' '}
<button
type="button"
disabled={show()}
onClick={() => {
setShow(true);
}}
>
Show children
</button>
{/* NOTE: The props.children are intentionally hidden by default
to simulate a situation where hydration script might not
be injected in the right spot. */}
<Show when={show()}>{props.children ?? 'Empty'}</Show>
</div>
);
}
export function AsyncErrorComponent() {
const [data] = createResource(async () => {
await sleep(SLEEP_MS);
throw new Error('Async error thrown!');
});
return <div>{data()}</div>;
}
export function AsyncErrorInErrorBoundary() {
return (
<ErrorBoundary fallback={<div>Async error boundary fallback</div>}>
<AsyncErrorComponent />
</ErrorBoundary>
);
}
export function SyncErrorComponent() {
throw new Error('Sync error thrown!');
}
export function SyncErrorInErrorBoundary() {
return (
<ErrorBoundary fallback={<div>Sync error boundary fallback</div>}>
<SyncErrorComponent />
</ErrorBoundary>
);
}
Domain
Subdomains
Functions
Dependencies
- solid-js
Source
Frequently Asked Questions
What does async-components.jsx do?
async-components.jsx is a source file in the astro codebase, written in javascript. It belongs to the IntegrationAdapters domain, ReactIntegration subdomain.
What functions are defined in async-components.jsx?
async-components.jsx defines 6 function(s): AsyncComponent, AsyncErrorComponent, AsyncErrorInErrorBoundary, SyncErrorComponent, SyncErrorInErrorBoundary, sleep.
What does async-components.jsx depend on?
async-components.jsx imports 1 module(s): solid-js.
Where is async-components.jsx in the architecture?
async-components.jsx is located at packages/astro/test/fixtures/solid-component/src/components/async-components.jsx (domain: IntegrationAdapters, subdomain: ReactIntegration, directory: packages/astro/test/fixtures/solid-component/src/components).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free