renderText don';我不能在光亮的地方工作
我有无功输出:renderText don';我不能在光亮的地方工作,r,shiny,R,Shiny,我有无功输出: {{ textOutput("fatalError") }} 它生成标签: <div id="fatalError" class="shiny-text-output shiny-bound-output"></div> 我有这样的代码: .events$fatalError <- list( errorMessage = "Unknow Error", index = 0L ) makeReactiveBinding("fata
{{ textOutput("fatalError") }}
它生成标签:
<div id="fatalError" class="shiny-text-output shiny-bound-output"></div>
我有这样的代码:
.events$fatalError <- list(
errorMessage = "Unknow Error",
index = 0L
)
makeReactiveBinding("fatalError", env = .events)
fatalError <- function(errorMessage) {
# the error is shown, the class fatal-error indicate that tag should be visible
addClass(selector = "body", class = "fatal-error")
.events$fatalError <- list(
errorMessage = errorMessage,
index = .events$fatalError$index + 1L
)
}
.events$fatalError发现问题,渲染时不能隐藏输出元素,否则它将无法工作(这可能是优化“功能”),可能是因为addClass在执行下一行之前不等待添加该类,因此renderText的输出不可见
observeEvent(.events$fatalError, {
# the message is printed to console
print(.events$fatalError$errorMessage)
output$fatalError <- renderText(.events$fatalError$errorMessage)
}, ignoreInit = TRUE)
output$fatalError <- renderText({
.events$fatalError$errorMessage
})