Skip to content

Handle shiny.tag.function dependencies #72

@kamilzyla

Description

@kamilzyla

Goal

The behavior of this app should be equivalent whether the selectInput() is wrapped in ReactContext() or not:

shinyApp(
  ui = shiny.react:::ReactContext(
    selectInput("select", "Select", c("Apples", "Bananas"))
  ),
  server = function(input, output) {}
)

Right now it gives the following error:

Error in FUN(X[[i]], ...) : 
  Expected a recursive structure built of NULLs, lists and dependencies

Root cause

Let's take a look at deparse(selectInput("select", "Select", c("Apples", "Bananas"))):

structure(
  list(
    # Omitted for brevity.
  ),
  class = "shiny.tag",
  html_dependencies = list(
    structure(
      function() {
        if (is_shiny_app()) {
          shiny::registerThemeDependency(func)
          return(mfunc(get_current_theme()))
        }
        mfunc(bs_global_get())
      },
      class = "shiny.tag.function" # The problem
    )
  )
)

The problem boils down to this: the flattenDeps() function doesn't handle arguments of class shiny.tag.function.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions