'use server' import React from 'react' import { fetchPosts } from './posts' export async function renderPosts() { const posts = await fetchPosts() posts.state = posts.state || { status: 'pending', promise: Promise.resolve(), } return (

Loading...
}> ) } function DelayedDateViaSuspense({ state }) { // a component that will suspend for 1 second and then show the current date if (state.status === 'pending') { state.promise = new Promise((resolve) => { setTimeout(() => { state.status = 'success' resolve() }, 5000) }) throw state.promise } return
{new Date().toISOString().replace('T', ' ').split('.')[0]}
} // ...fetchPosts // posts // ...5000 // timestamp