Unify is_external prop in rx.redirect and rx.link

This commit is contained in:
Elijah 2024-11-18 13:38:20 +00:00
parent dc347d10b3
commit f0f6566489

View File

@ -705,6 +705,7 @@ def server_side(name: str, sig: inspect.Signature, **kwargs) -> EventSpec:
def redirect( def redirect(
path: str | Var[str], path: str | Var[str],
external: Optional[bool] = False, external: Optional[bool] = False,
is_external: Optional[bool] = False,
replace: Optional[bool] = False, replace: Optional[bool] = False,
) -> EventSpec: ) -> EventSpec:
"""Redirect to a new path. """Redirect to a new path.
@ -712,16 +713,26 @@ def redirect(
Args: Args:
path: The path to redirect to. path: The path to redirect to.
external: Whether to open in new tab or not. external: Whether to open in new tab or not.
is_external: Whether to open in new tab or not.
replace: If True, the current page will not create a new history entry. replace: If True, the current page will not create a new history entry.
Returns: Returns:
An event to redirect to the path. An event to redirect to the path.
""" """
if external:
console.deprecate(
"The `external` prop in `rx.redirect`",
"use `is_external` instead.",
"0.6.6",
"0.7.0",
)
is_external = external
return server_side( return server_side(
"_redirect", "_redirect",
get_fn_signature(redirect), get_fn_signature(redirect),
path=path, path=path,
external=external, external=is_external,
replace=replace, replace=replace,
) )