Open
Description
Summary
The docs on RSC should mention whether Promises passed from Server Components can be used without use()
.
Page
https://react.dev/reference/rsc/server-components
Details
Currently, the docs only discuss resolving Promises passed from the server using use()
. Sometimes it can be useful to render a component with partial data and update its state once the promise is fulfilled. This appears to work.:
"use client";
export default function Component({ promise }) {
const [data, setData] = useState(null);
useEffect(() => {
let canceled = false;
promise.then((d) => !canceled && setData(d));
return () => canceled = true;
}, [promise])
return (<p>{data}</p>);
}
However I can't find any mentions of this use case. I think that if this is officially supported, there should be an example showing how to do it. And if not, that should be explicitly stated.