From c5b562a83fb8a4eefd1681393123dee051dd1067 Mon Sep 17 00:00:00 2001 From: simon-smart88 Date: Fri, 12 Dec 2025 15:12:08 +0000 Subject: [PATCH 1/2] return error when renderXXX is used in UI --- R/shinywrappers.R | 6 ++++++ tests/testthat/test-shinywrappers.R | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/R/shinywrappers.R b/R/shinywrappers.R index dca587398c..40ae4a85a7 100644 --- a/R/shinywrappers.R +++ b/R/shinywrappers.R @@ -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.") + } + useRenderFunction(x, inline = inline) } diff --git a/tests/testthat/test-shinywrappers.R b/tests/testthat/test-shinywrappers.R index 4de1794963..5b517c97d3 100644 --- a/tests/testthat/test-shinywrappers.R +++ b/tests/testthat/test-shinywrappers.R @@ -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) From 49b76118486c065b1627109f58d0338824dd7275 Mon Sep 17 00:00:00 2001 From: simon-smart88 Date: Fri, 12 Dec 2025 15:23:47 +0000 Subject: [PATCH 2/2] update NEWS --- NEWS.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS.md b/NEWS.md index 93a4192e81..44095dde46 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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