Hello everyone,
I am writing an RMarkdown document with runtime = shiny_prerendered, but having trouble accessing what should be a global variable.
Basically, I want the user to upload a file to the document. Once that happens, the variable FILE_VALID will switch from FALSE to TRUE. If FILE_VALID == TRUE, a text message should render elsewhere in the document. However, the message does not render even when the value of FILE_VALID changes.
I did my best to create a reprex of the document using online tutorials for guidance, but I think I was unsuccessful. Therefore, I hope you will accept my RMarkdown code as a stand-in reprex.
If anyone can spot the bug(s) in my code, would you please share your insight?
---
title: "Reprex"
output: html_document
---
```{r setup, include=FALSE}
library(shiny)
library(rmarkdown)
knitr::opts_chunk$set(echo = TRUE)
```
```{r load_file}
fluidPage(
fileInput('file', 'Load any file and then click "Verify file":'),
actionButton('verify', 'Verify file')
)
FILE_VALID <<- FALSE
```
```{r, context = 'server'}
observeEvent(input$file, {
if (isTruthy(input$load_file_upload) == FALSE) {
FILE_VALID <<- TRUE
}
})
```
```{r show_text}
fluidPage(
textOutput('text')
)
```
```{r, context = 'server'}
output$text <- renderText({
if (FILE_VALID == TRUE) {
print("hi")
}
})
```
```