Getting rid of the renderUI
Let’s observe the effect of slow rendering.
The whole piece of UI is re-rendered each time, while only the box class should be modified.
library(shiny)
library(shinyWidgets)
library(OSUICode)
ui <- fluidPage(
# import shinydashboard deps without the need of the
# dashboard template
useShinydashboard(),
tags$style("body { background-color: ghostwhite};"),
br(),
uiOutput("custom_box"),
br(),
br(),
selectInput(
"widthvalue",
"Width Value",
choices = 6:12
)
)
server <- function(input, output, session) {
dummy_task <- reactive({
Sys.sleep(5)
input$widthvalue
})
output$custom_box <- renderUI({
dummy_task()
box(
title = "Box",
width = dummy_task(),
"Box body",
background = "blue"
)
})
}
shinyApp(ui, server)