According to Chapter 3 Basic reactivity | Mastering Shiny and my previous experience the below code should throw an error like
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.)
However, it does not and seems to work without a problem. My problem is that now I am confused if I understand reactivity or not. (I still get the error if I try to use input from not in a function.
library("shiny")
ui <- fluidPage(
checkboxInput("test", "test"),
textOutput("text")
)
server <- function(input, output) {
# this throws error as expected
# message(input$test)
test_value <- function() {
input$test
}
output$text <- renderText({
test_value()
})
}
shinyApp(ui = ui, server = server)
Probably I am missing something. Thanks!