I'm trying to create an app creates a simple list (actives$name
) of strings, and shows me back those strings.
For some reason, it doesn't work. Here's the code:
library(shiny)
ui <- fluidPage(
sidebarLayout(
mainPanel(
textInput(inputId = "name", label = "Name", value = "foo"),
actionButton(inputId = "add", label = "Add")
),
sidebarPanel(
uiOutput("activeB")
)
),
)
server <- function(input, output, session) {
actives <- reactiveValues()
observeEvent(input$add,{
actives$name <- c(actives$name, input$name)
})
output$activeB <- renderUI({
for (i in 1:length(actives$name)) {
p("Name:")
verbatimTextOutput(actives$name[i])
print(actives$name[i])
}
})
}
shinyApp(ui = ui, server = server)
The print()
I'm using in the for
loop shows the correct result, so it "knows" what I'm trying to do. It just doesn't output it. What am I doing wrong?