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

React context can affect layout #52

Open kamilzyla opened 1 year ago

kamilzyla commented 1 year ago

Problem

To ensure that Shiny inputs/outputs work when rendered by React, we use ShinyBindingWrapper. Unfortunately it adds an additional wrapper div into the rendered HTML, which makes it harder to read and can affect layout/styling.

The following snippet will render "Hi" and "there!" on separate lines. If we replace shiny.react:::ReactContext with tagList, both words will appear on one line.

shinyApp(
  ui = shiny.react:::ReactContext(
    actionLink("a", "Hi"),
    actionLink("b", "there!")
  ),
  server = function(input, output) {}
)

A similar issue can be observed for textOutput():

shinyApp(
  ui = shiny.react:::ReactContext(
    textOutput("a", inline = TRUE),
    textOutput("b", inline = TRUE)
  ),
  server = function(input, output) {
    output$a <- renderText("Hi")
    output$b <- renderText("there!")
  }
)

Solution

It is possible to avoid the wrapper div; a preliminary solution is available on with-shiny-bindings branch.