lbry-desktop/ui/page/embedWrapper/view.jsx

33 lines
720 B
React
Raw Normal View History

// @flow
2020-04-14 01:48:11 +02:00
import React, { useEffect } from 'react';
import FileRender from 'component/fileRender';
type Props = {
uri: string,
resolveUri: string => void,
claim: Claim,
};
2020-01-31 19:25:48 +01:00
// $FlowFixMe apparently flow thinks this is wrong.
export const EmbedContext = React.createContext();
const EmbedWrapperPage = (props: Props) => {
2020-04-14 01:48:11 +02:00
const { resolveUri, claim, uri } = props;
2020-01-31 20:33:40 +01:00
useEffect(() => {
if (resolveUri && uri) {
resolveUri(uri);
}
2020-04-14 01:48:11 +02:00
}, [resolveUri, uri]);
2020-01-31 19:25:48 +01:00
return (
<div className={'embed__wrapper'}>
{claim && (
<EmbedContext.Provider value>
2020-04-14 01:48:11 +02:00
<FileRender uri={uri} embedded />
2020-01-31 19:25:48 +01:00
</EmbedContext.Provider>
)}
</div>
);
};
export default EmbedWrapperPage;