Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# shiny (development version)

## Bug fixes and minor improvements

* Using `renderXXX` functions in the UI will now return an error (#4189).

# shiny 1.12.1

## New features
Expand Down
6 changes: 6 additions & 0 deletions R/shinywrappers.R
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,12 @@ useRenderFunction <- function(renderFunc, inline = FALSE) {
#' @export
#' @method as.tags shiny.render.function
as.tags.shiny.render.function <- function(x, ..., inline = FALSE) {
# return an error when render functions are used in UI
if (is.null(getDefaultReactiveDomain())) {
stop("There is a renderXXX function in the UI, these should only be used in the server function.",
"Use the corresponding XXXOutput function in the UI instead.")
}
Comment on lines +331 to +335
Copy link
Collaborator

@cpsievert cpsievert Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shoot, sorry. I gave bad advice in #4189. We can't throw an error in this case -- if we do, we'll break renderXXX() usage inside of R Markdown. Unfortunately, I'm not sure there's sensible approach to throwing this error 😞


useRenderFunction(x, inline = inline)
}

Expand Down
5 changes: 5 additions & 0 deletions tests/testthat/test-shinywrappers.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
test_that("render functions in UI throw informative error", {
expect_error(as.tags.shiny.render.function(renderTable("table")),
"There is a renderXXX function in the UI")
})

test_that("isTemp passes sanity checks", {
t <- tempfile(fileext = ".txt")
writeLines("hello", t)
Expand Down