This is part of server.R:
counter <- reactiveValues(n = 0)
output$counter <- renderPrint(print(counter$n))
observeEvent(input$addRow, {
if (counter$n < 5)
counter$n <- counter$n + 1
})
observeEvent(input$delRow, {
if (counter$n > 0)
counter$n <- counter$n - 1
})
output[[paste0("additional_row_", counter$n)]] <- renderUI({ inputs() }) #for example, inputs is an h4("Hello"). It really is a couple of UI elements.. But first let's make it to work with only 1
And ui.R:
uiOutput("additional_row_1"),
uiOutput("additional_row_2"),
uiOutput("additional_row_3"),
uiOutput("additional_row_4"),
uiOutput("additional_row_5"),
actionButton("addRow", "Add Row"),
actionButton("delRow", "Delete Row"),
uiOutput("counter"),
The error says:
Error in .getReactiveEnvironment()$currentContext() : Operation not allowed without an active reactive context. (You tried to do something that can only be done from inside a reactive expression or observer.)
And I understand it, because I try to compute the name of an output. But how then can I add rows and delete rows of UI elements in my app?
I appreciate your help. Thank you very much