Why there is a TRUE in the bottom?


#1

I'm trying to build an app to show different ui based on different conditions.

When I source a ui file, there is a TRUE printed after run the app. I don't want to see it.

https://shizidushu.shinyapps.io/true/

app.R

library(shiny)
library(shinydashboard)
ui <- source("ui-test.R")

server <- function(input, output) {
    
}

# Run the application 
shinyApp(ui = ui, server = server)

ui-test.R

dashboardPage(
  dashboardHeader(title = "dashboard", disable = TRUE),
  ## Sidebar content
  dashboardSidebar(
    sidebarMenu(
      menuItem("dashboard", tabName = "dashboard", icon = icon("dashboard"))
    ),
    collapsed = TRUE
  ),
  dashboardBody(
    fluidRow(
      
    )
  )
)

#2

I found this answer on StackOverflow that seems to indicate it is due to the sourcing of the UI:

The answer seems to be to change ui <- source("ui-test.R") to ui <- source("ui-test.R", local = TRUE)$value