You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello! We have a series of checkout extensions built using the vanilla JS (non-React) set of libraries and components. Our approach was to use the htm method from the (now-deprecated) @remote-ui/htm library to make our markup easier to reason about. eg:
The new Shopify recommended way of interacting with the DOM for those not using React is to use a series of nested root.createComponent calls, which results in code that is harder to mentally parse than its React equivalent. The differences can be seen here.
React:
return(<InlineStack><Imagesource="/url/for/image"/><BlockStack><Textsize="large">Heading</Text><Textsize="small">Description</Text></BlockStack><ButtononPress={()=>{console.log('button was pressed');}}>
Button
</Button></InlineStack>);
JS:
constinlineStack=root.createComponent(InlineStack,{},[root.createComponent(Image,{source: '/url/for/image',}),root.createComponent(BlockStack,{},[root.createComponent(Text,{size: 'large'},'Heading',),root.createComponent(Text,{size: 'small'},'Description',),]),root.createComponent(Button,{onPress: ()=>{console.log('button was pressed');},},'Button',),],);
Are there any examples available using Shopify's recommended@remote-dom library for accomplishing the same thing using react-like declarative markup the way we previously did using @remote-ui/htm? We've looked through the Migration Guide which does state:
but other than the new method being called html (probably a small typo here?) that method seems to rely on full access to document. which does not exist in the extensions sandbox context. Are there any examples anywhere for building a UI without using nested createComponent calls?
Thanks!
The text was updated successfully, but these errors were encountered:
Hello! We have a series of checkout extensions built using the vanilla JS (non-React) set of libraries and components. Our approach was to use the
htm
method from the (now-deprecated)@remote-ui/htm
library to make our markup easier to reason about. eg:The new Shopify recommended way of interacting with the DOM for those not using React is to use a series of nested
root.createComponent
calls, which results in code that is harder to mentally parse than its React equivalent. The differences can be seen here.React:
JS:
Are there any examples available using Shopify's recommended
@remote-dom
library for accomplishing the same thing using react-like declarative markup the way we previously did using@remote-ui/htm
? We've looked through the Migration Guide which does state:but other than the new method being called
html
(probably a small typo here?) that method seems to rely on full access todocument.
which does not exist in the extensions sandbox context. Are there any examples anywhere for building a UI without using nestedcreateComponent
calls?Thanks!
The text was updated successfully, but these errors were encountered: