reactiveVal function error

Hi There,

I ran this coding:

if (interactive()) {
  
  ui <- fluidPage(
    actionButton("minus", "-1"),
    actionButton("plus", "+1"),
    br(),
    textOutput("value")
  )
  
  # The comments below show the equivalent logic using reactiveValues()
  server <- function(input, output, session) {
    value <- reactiveVal(0)       # rv <- reactiveValues(value = 0)
    
    observeEvent(input$minus, {
      newValue <- value() - 1     # newValue <- rv$value - 1
      value(newValue)             # rv$value <- newValue
    })
    
    observeEvent(input$plus, {
      newValue <- value() + 1     # newValue <- rv$value + 1
      value(newValue)             # rv$value <- newValue
    })
    
    output$value <- renderText({
      value()                     # rv$value
    })
  }
  
  shinyApp(ui, server)
  
}

which I copied from RStudio, and got this error: Error in server(...) : could not find function "reactiveVal"

I copied some coding from what appears to be the function on git but still can't get it to work.

Thanks for any support,
gwynn

What version of Shiny are you using, and have you definitely loaded Shiny (e.g. with library())?

Shiny was loaded. Version ‘1.0.0’

i copied the code from above and works fine. Shiny version 1.0.5. Maybe an update will help.

I hope an update won't break anything of my other coding... Thanks