From cee535bdbf16a5cb5cabb9224986eb578996e453 Mon Sep 17 00:00:00 2001 From: lgnbhl Date: Sun, 15 Jun 2025 12:16:01 +0200 Subject: [PATCH 1/2] `reloadDocument` argument FALSE by default in `Link()` and `NavLink()`. Update dynamic-segmnent example to add `reloadDocument = TRUE` in links --- R/components.R | 16 ++++++++-------- inst/examples/dynamic-segment/app.R | 3 +++ man/Link.Rd | 8 ++++---- man/NavLink.Rd | 8 ++++---- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/R/components.R b/R/components.R index 5a1980b..e44ff0f 100644 --- a/R/components.R +++ b/R/components.R @@ -75,13 +75,13 @@ Route <- function(..., element, key = uuid::UUIDgenerate()) { #' Link #' #' The `reloadDocument` can be used to skip client side routing and let the -#' browser handle the transition normally (as if it were an ). In -#' React Router v6 `reloadDocument` if `FALSE`, but given shiny behavior, the -#' `Link()` function makes it `TRUE` by default. +#' browser handle the transition normally (as if it were an ). Given +#' shiny behavior, using `reloadDocument = TRUE` allows to render correctly +#' objects created in the server side. #' #' @rdname Link #' @param ... Props to pass to element. -#' @param reloadDocument Boolean. Default TRUE. Let browser handle the transition normally +#' @param reloadDocument Boolean. Default FALSE. #' @return A Link component. #' @export Link <- function(..., reloadDocument = TRUE) { @@ -107,13 +107,13 @@ Navigate <- component('Navigate') #' NavLink #' #' The `reloadDocument` can be used to skip client side routing and let the -#' browser handle the transition normally (as if it were an ). In -#' React Router v6 `reloadDocument` if `FALSE`, but given shiny behavior, the -#' `NavLink()` function makes it `TRUE` by default. +#' browser handle the transition normally (as if it were an ). Given +#' shiny behavior, using `reloadDocument = TRUE` allows to render correctly +#' objects created in the server side. #' #' @rdname NavLink #' @param ... Props to pass to element. -#' @param reloadDocument Boolean. Default TRUE. Let browser handle the transition normally +#' @param reloadDocument Boolean. Default FALSE. #' @return A NavLink component. #' @export NavLink <- function(..., reloadDocument = TRUE) { diff --git a/inst/examples/dynamic-segment/app.R b/inst/examples/dynamic-segment/app.R index 178e103..5b72ae8 100644 --- a/inst/examples/dynamic-segment/app.R +++ b/inst/examples/dynamic-segment/app.R @@ -90,12 +90,14 @@ ui <- reactRouter::HashRouter( nav_item( NavLink( to = "overview", + reloadDocument = TRUE, "Overview" ) ), nav_item( NavLink( to = "analysis", + reloadDocument = TRUE, "Analysis" ) ), @@ -103,6 +105,7 @@ ui <- reactRouter::HashRouter( nav_item( NavLink( to = "/", + reloadDocument = TRUE, shiny::icon("home") ) ), diff --git a/man/Link.Rd b/man/Link.Rd index 0b2513c..b7f7c69 100644 --- a/man/Link.Rd +++ b/man/Link.Rd @@ -6,7 +6,7 @@ \alias{updateLink.shinyInput} \title{Link} \usage{ -Link(..., reloadDocument = TRUE) +Link(..., reloadDocument = FALSE) Link.shinyInput(inputId, ..., reloadDocument = TRUE) @@ -30,9 +30,9 @@ A Link component. } \description{ The `reloadDocument` can be used to skip client side routing and let the -browser handle the transition normally (as if it were an ). In -React Router v6 `reloadDocument` if `FALSE`, but given shiny behavior, the -`Link()` function makes it `TRUE` by default. +browser handle the transition normally (as if it were an ). Given +shiny behavior, using `reloadDocument = TRUE` allows to render correctly +objects created in the server side. \url{https://reactrouter.com/6.30.0/components/link} } diff --git a/man/NavLink.Rd b/man/NavLink.Rd index 96cee6c..d9b46dd 100644 --- a/man/NavLink.Rd +++ b/man/NavLink.Rd @@ -6,7 +6,7 @@ \alias{updateNavLink.shinyInput} \title{NavLink} \usage{ -NavLink(..., reloadDocument = TRUE) +NavLink(..., reloadDocument = FALSE) NavLink.shinyInput(inputId, ..., reloadDocument = TRUE) @@ -30,9 +30,9 @@ A NavLink component. } \description{ The `reloadDocument` can be used to skip client side routing and let the -browser handle the transition normally (as if it were an ). In -React Router v6 `reloadDocument` if `FALSE`, but given shiny behavior, the -`NavLink()` function makes it `TRUE` by default. +browser handle the transition normally (as if it were an ). Given +shiny behavior, using `reloadDocument = TRUE` allows to render correctly +objects created in the server side. \url{https://reactrouter.com/6.30.0/components/nav-link} } From 8a8068db9b6ace11c4772184ed93b0f3e34c6435 Mon Sep 17 00:00:00 2001 From: lgnbhl Date: Sun, 15 Jun 2025 12:26:22 +0200 Subject: [PATCH 2/2] update docs --- man/Link.Rd | 2 +- man/NavLink.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/man/Link.Rd b/man/Link.Rd index b7f7c69..0ce089f 100644 --- a/man/Link.Rd +++ b/man/Link.Rd @@ -6,7 +6,7 @@ \alias{updateLink.shinyInput} \title{Link} \usage{ -Link(..., reloadDocument = FALSE) +Link(..., reloadDocument = TRUE) Link.shinyInput(inputId, ..., reloadDocument = TRUE) diff --git a/man/NavLink.Rd b/man/NavLink.Rd index d9b46dd..f116bc3 100644 --- a/man/NavLink.Rd +++ b/man/NavLink.Rd @@ -6,7 +6,7 @@ \alias{updateNavLink.shinyInput} \title{NavLink} \usage{ -NavLink(..., reloadDocument = FALSE) +NavLink(..., reloadDocument = TRUE) NavLink.shinyInput(inputId, ..., reloadDocument = TRUE)