const loadAboutData = cache(async () => {
return new Promise((resolve) =>
setTimeout(resolve, 500, "Solid")
) as Promise<string>;
}, "about");
export default function About() {
const name = createAsync(() => loadAboutData());
return (
<section class="p-8">
<Suspense fallback={<p>...</p>}>
<p>{name()}</p>
</Suspense>
<button
onClick={() => {
// optimistically update the dat
mutate((name) => “UpdatedName”)
// api call to update
}}>
Test
</button>
</section>
);
}
const loadAboutData = cache(async () => {
return new Promise((resolve) =>
setTimeout(resolve, 500, "Solid")
) as Promise<string>;
}, "about");
export default function About() {
const name = createAsync(() => loadAboutData());
return (
<section class="p-8">
<Suspense fallback={<p>...</p>}>
<p>{name()}</p>
</Suspense>
<button
onClick={() => {
// optimistically update the dat
mutate((name) => “UpdatedName”)
// api call to update
}}>
Test
</button>
</section>
);
}