pos. exchange. post. block. renderTarget
Target
Renders a custom section within the native post exchange screen
Note
This is part of a POS UI Extensions developer preview. More information to come.
Was this section helpful?
Block
import React from 'react';
import {
POSBlock,
POSBlockRow,
Text,
reactExtension,
useApi,
} from '@shopify/ui-extensions-react/point-of-sale';
const ExchangeBlock = () => {
const api = useApi<'pos.exchange.post.block.render'>();
return (
<POSBlock
action={{
title: 'View exchange details',
onPress: api.action.presentModal,
}}
>
<POSBlockRow>
<Text>{'Exchange block extension'}</Text>
<Text>{`Order ID: ${api.order.id}`}</Text>
</POSBlockRow>
</POSBlock>
);
};
export default reactExtension('pos.exchange.post.block.render', () => (
<ExchangeBlock />
));
examples
Block
React
import React from 'react'; import { POSBlock, POSBlockRow, Text, reactExtension, useApi, } from '@shopify/ui-extensions-react/point-of-sale'; const ExchangeBlock = () => { const api = useApi<'pos.exchange.post.block.render'>(); return ( <POSBlock action={{ title: 'View exchange details', onPress: api.action.presentModal, }} > <POSBlockRow> <Text>{'Exchange block extension'}</Text> <Text>{`Order ID: ${api.order.id}`}</Text> </POSBlockRow> </POSBlock> ); }; export default reactExtension('pos.exchange.post.block.render', () => ( <ExchangeBlock /> ));
TS
import { POSBlock, POSBlockRow, Text, extension, } from '@shopify/ui-extensions/point-of-sale'; export default extension('pos.exchange.post.block.render', (root, api) => { const block = root.createComponent(POSBlock, { action: {title: 'View exchange details', onPress: api.action.presentModal}, }); const mainText = root.createComponent(Text); mainText.append('Exchange block extension'); const subtitleText = root.createComponent(Text); subtitleText.append(`Order ID: ${api.order.id}`); const blockMainRow = root.createComponent(POSBlockRow); blockMainRow.append(mainText); const blockSubtitleRow = root.createComponent(POSBlockRow); blockSubtitleRow.append(subtitleText); block.append(blockMainRow); block.append(blockSubtitleRow); root.append(block); });