Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

Admin Block Extension Output HTML

Admin Block Extension Output HTML

midavis
Shopify Partner
9 0 1

I have an admin extension on the order info screen.   I am loading data from a 3rd party source and I would like to output this data to the page.  Some of this data is html, however when I output it to the screen it shows the raw html.  Is there a way to insert it as html instead of rending it as text?

 

Screenshot 2024-10-15 143823.png

Reply 1 (1)

gojiberry-des
Shopify Partner
29 7 5

It is probably React escaping strings with special characters.

Try using dangerouslySetInnerHtml: https://react.dev/reference/react-dom/components/common#dangerously-setting-the-inner-html

But make sure where you are getting your HTML from is a trusted source or it could be vulnerable to script injection.

If you like my suggestion please give it a LIKE or mark it as a solution! ★★★★★

Gojiberry - Best post-purchase survey and feedback app for Shopify | Install on App Store for free
Shopify Community is helpful, BUT... why not start asking your customers for feedback instead?