Using shiny modules and shinydashboard: shiny.tag error

后端 未结 3 1911
孤城傲影
孤城傲影 2021-01-06 19:32

I\'m trying to create and use shiny modules inside a shinydashboard app but I keep getting this error:

Error in FUN(X[[i]], ...) : Expected an object with cl         


        
3条回答
  •  误落风尘
    2021-01-06 20:30

    Two things:

    1. Seems tabName is necessary in the menuItem function
    2. Move tabItem from the module to ui (tabItem can hold you module)

    UI

    ui <- dashboardPage(
      dashboardHeader(
        title = "Shiny modules and shinydashboard"
      ),
    
      dashboardSidebar(
        sidebarMenu(
          menuItem("PointA", tabName = "PointA") 
        )
      ),
    
      dashboardBody(
        tabItems(
          tabItem("PointA",
                  fooUI("myid")
          )
        )
      )
    )
    

    Module

    fooUI <- function(id) {
      ns <- NS(id)
    
      tagList(
        tabName = "PointA",
        textOutput(ns("text"))
      )
    }
    
    foo <- function(input, output, session){
    
      output$text <- renderText(
        rnorm(1)
      )
    }
    

提交回复
热议问题