import type {ReactElement} from 'react'; import {render as remoteRender} from '@remote-ui/react'; import {extend} from '@shopify/post-purchase-ui-extensions'; import type { RenderExtensionPoint, InputForRenderExtension, } from '@shopify/post-purchase-ui-extensions'; import {ExtensionInputContext} from './context'; export function render( extensionPoint: ExtensionPoint, render: (input: InputForRenderExtension) => ReactElement, ) { // TypeScript can’t infer the type of the callback because it’s a big union // type. To get around it, we’ll just fake like we are rendering the // KitchenSink extension, since all render extensions have the same general // shape (`RenderExtension`). return extend<'Checkout::KitchenSink'>( extensionPoint as any, (root, input) => { remoteRender( {render(input as InputForRenderExtension)} , root, () => { root.mount(); }, ); return {}; }, ); }