Skip to content

Commit 1723f8d

Browse files
committed
prefix uuid with a string
1 parent fa0f307 commit 1723f8d

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/reactpy_router/components.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ def link(*children: VdomChild, to: str, **attributes: Any) -> VdomDict:
2626
# properly sets the location. When a client-server communication layer is added to a \
2727
# future ReactPy release, this component will need to be rewritten to use that instead. \
2828
set_location = _use_route_state().set_location
29-
uuid = uuid4().hex
29+
class_uuid = f"link-{uuid4().hex}"
3030

3131
def on_click(_event: dict[str, Any]) -> None:
3232
pathname, search = to.split("?", 1) if "?" in to else (to, "")
3333
if search:
3434
search = f"?{search}"
3535
set_location(Location(pathname, search))
3636

37-
class_name = uuid
37+
class_name = class_uuid
3838
if "className" in attributes:
3939
class_name = " ".join([attributes.pop("className"), class_name])
4040
# TODO: This can be removed when ReactPy stops supporting underscores in attribute names
@@ -45,9 +45,9 @@ def on_click(_event: dict[str, Any]) -> None:
4545
**attributes,
4646
"href": to,
4747
"onClick": on_click,
48-
"className": uuid,
48+
"className": class_uuid,
4949
}
50-
return html._(html.a(attrs, *children), html.script(link_js_content.replace("UUID", uuid)))
50+
return html._(html.a(attrs, *children), html.script(link_js_content.replace("UUID", class_uuid)))
5151

5252

5353
def route(path: str, element: Any | None, *routes: Route) -> Route:

src/reactpy_router/static/link.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
document.getElementsByClassName("UUID").addEventListener("click", (event) => {
1+
document.querySelector(".UUID").addEventListener("click", (event) => {
22
event.preventDefault();
33
let to = event.target.getAttribute("href");
44
window.history.pushState({}, to, new URL(to, window.location));

0 commit comments

Comments
 (0)