This commit is contained in:
@@ -216,11 +216,20 @@ interface LinkEmbedProps {
|
||||
}
|
||||
|
||||
export function LinkEmbed({ url, onOpenGif }: LinkEmbedProps) {
|
||||
// Thin router: direct media gets its own component, rich previews
|
||||
// get theirs. Keeping the two paths in separate component instances
|
||||
// means `useUrlPreview` (which internally wraps `useAction` and
|
||||
// therefore `useMemo`) is never called conditionally — otherwise a
|
||||
// URL change that flipped `isDirectMedia` would mutate the hook
|
||||
// count and trigger React error #310.
|
||||
const directType = isDirectMedia(url);
|
||||
if (directType) {
|
||||
return <DirectMediaEmbed url={url} type={directType} onOpenGif={onOpenGif} />;
|
||||
}
|
||||
return <UrlPreviewEmbed url={url} />;
|
||||
}
|
||||
|
||||
function UrlPreviewEmbed({ url }: { url: string }) {
|
||||
const preview = useUrlPreview(url);
|
||||
|
||||
// If the platform has no metadata fetcher (or it returned null / threw),
|
||||
|
||||
Reference in New Issue
Block a user