title: R Shiny: Can't access reactive value outside of reactive consumer
body: <p>I am trying to build a Shiny app that performs some modifications to a raster file, plots it and gives option to download (modified) raster files. I am getting the following error:</p>
  <pre><code>Listening on http://127.0.0.1:3371
  Warning: Error in : Can't access reactive value 'divider' outside of reactive consumer.
  ℹ Do you need to wrap inside reactive() or observer()?
    53: &lt;Anonymous&gt;
  Error : Can't access reactive value 'divider' outside of reactive consumer.
  ℹ Do you need to wrap inside reactive() or observer()?
  </code></pre>
  <p>What am I doing wrong? I found <a href="https://community.rstudio.com/t/reactive-value-problem/96194" rel="noreferrer">this</a> related question on RStudio community but it didn't help me. Could anyone please help me understand this?</p>
  <p><strong>Minimum Working Example</strong></p>
  <blockquote>
  <p>ui.R</p>
  </blockquote>
  <pre><code>shinyUI(fluidPage(
  
      # Application title
      titlePanel(&quot;Urban-Rural Raster Population&quot;),
  
      # Sidebar 
      sidebarLayout(
          sidebarPanel(
              sliderInput(&quot;divider&quot;,
                          &quot;Divider number:&quot;,
                          min = 1,
                          max = 29,
                          value = 7),
              downloadButton(&quot;download1&quot;, &quot;Download Rural Raster&quot;),
              downloadButton(&quot;download2&quot;, &quot;Download Urban Raster&quot;)
          ),
  
          # plots
          mainPanel(
              plotOutput(&quot;plot1&quot;),
              plotOutput(&quot;plot2&quot;)
          )
      )
  ))
  </code></pre>
  <blockquote>
  <p>server.R</p>
  </blockquote>
  <pre><code># Loading all external data - so that its done only once
  rast_pop = read_stars(&quot;ind_ppp_2020_1km_Aggregated_UNadj.tif&quot;, proxy = F)
  urca_raster = read_stars(&quot;URCA.tif&quot;, proxy = T)
  names(urca_raster) = &quot;urca&quot;
  
  # Finding rasters for India's boundaries
  ind_shp = st_as_sf(getData('GADM', country ='IND', level = 0)) # for country
  ind_st_shp = st_as_sf(getData('GADM', country ='IND', level = 1))  #for states boundary
  ind_dis_shp = st_as_sf(getData('GADM', country = 'IND', level = 2)) # for district boundary
  
  # cropping India from raster
  ind_urca = st_crop(urca_raster, ind_shp)
  
  
  # Define server logic 
  shinyServer(function(input, output) {
  
      div_ru = input$divider
      
      # dividing on the basis of rural and urban
      ind_rur = ind_urca &gt; div_ru
      ind_urb = ind_urca &lt;= div_ru
      ind_rur_star = st_as_stars(ind_rur)
      ind_urb_star = st_as_stars(ind_urb)
      
      output$plot1 = renderPlot({
          plot(ind_rur_star)
          })
      
      output$plot2 = renderPlot({
          plot(ind_urb_star)
      })
      
      output$download1 = downloadHandler(
          filename = function() {
              paste0(&quot;rural_raster_&quot;, input$divider, &quot;.tif&quot;)
              },
          content = function(file) {
              write_stars(ind_rur_star, file, layer = 1)
          }
      )
      output$download2 = downloadHandler(
          filename = function() {
              paste0(&quot;urban_raster_&quot;, input$divider, &quot;.tif&quot;)
          },
          content = function(file) {
              write_stars(ind_urb_star, file, layer = 1)
          }
      )
  })
  </code></pre>