react/no-unstable-nested-components not needed in React Server Components? #3883
Open
Description
Hi @ljharb, hope you're well!
I wanted to confirm a suspicion that I have:
Since React Server Components are rendered on the server and do not follow the same re-rendering patterns as Client Components, my guess is that declaring functions inside of Server Components does not follow the same pitfalls, and probably enabling react/no-unstable-nested-components
does not enjoy the same benefits. Maybe it's not needed in RSC?
The pattern I'm trying to achieve is "currying in" various server-fetched pieces of information (in this case, props.video
) into MDX components passed to an imported MDXContent
:
import { LectureVideo } from './LectureVideo.tsx';
type Props = {
lectureSlug: LectureType['slug'];
video: Video;
};
export default async function Lecture(props: Props) {
let MDXContent: (props: LectureMdxProps & { readonly components: MDXComponents | undefined; })
=> JSX.Element;
try {
MDXContent = (await import `./lectures/${props.lectureSlug}/index.mdx`).default;
} catch {
notFound();
}
return (
<MDXContent
components={
{
// eslint-disable-next-line react/no-unstable-nested-components -- Not problematic in this position in RSC?
LectureVideo: (
// propsFromMdx doesn't contain `videoYoutubeId`
propsFromMdx: Omit<ComponentProps<typeof LectureVideo>, 'videoYoutubeId'>,
) => {
return (
<LectureVideo
{...propsFromMdx}
// "currying in" pattern:
// props.video.youtubeId is queried from the database and passed down via props
videoYoutubeId={props.video.youtubeId}
/>
);
},
} satisfies MDXComponents
}
/>
);
}
CodeSandbox demo: https://codesandbox.io/p/devbox/fast-tree-x7zpn2?file=%2Fapp%2Fblog%2F%5Bslug%5D%2FLectureVideo.tsx%3A5%2C1
Metadata
Assignees
Labels
No labels