Appsilon / shiny.react

Use React in Shiny applications.
https://appsilon.github.io/shiny.react
GNU Lesser General Public License v3.0
96 stars 12 forks source link

Add support for `HTML()` within React #13

Closed kamilzyla closed 1 year ago

kamilzyla commented 3 years ago

In React context, htmltools::HTML() is treated as plain text. It should be however possible to make React render the HTML. Two options come to mind:

  1. Insert a div and use its dangerouslySetInnerHTML. This solution has a drawback of creating an additional wrapper div - might be undesirable, if the user wants strict control over the HTML structure.
  2. Parse the HTML with html-react-parser to get a React element and render it.

Note: A workaround for now is to add a uiOutput() in place of HTML() and render the desired HTML dynamically.