mirror of
https://github.com/LukeHagar/unicorn-utterances.git
synced 2025-12-06 21:07:47 +00:00
25 lines
518 B
JavaScript
25 lines
518 B
JavaScript
import { use, cache } from "react";
|
|
|
|
// Still using cache... For now...
|
|
const fetchOurUserFromTheDatabase = cache(() => {
|
|
return new Promise((resolve) => {
|
|
setTimeout(() => {
|
|
resolve({
|
|
name: "John Doe",
|
|
age: 34,
|
|
});
|
|
}, 1000);
|
|
});
|
|
});
|
|
|
|
function UserDetails() {
|
|
/* This also works, but is still not the best way
|
|
of doing things in server components */
|
|
const user = use(fetchOurUserFromTheDatabase());
|
|
return <p>{user.name}</p>;
|
|
}
|
|
|
|
export default function Home() {
|
|
return <UserDetails />;
|
|
}
|