88from reactpy import component , html , use_connection
99from reactpy .backend .types import Location
1010from reactpy .core .component import Component
11- from reactpy .core .types import VdomDict
11+ from reactpy .core .types import Key , VdomDict
1212from reactpy .web .module import export , module_from_file
1313
1414from reactpy_router .hooks import _use_route_state
4040link_js_content = (Path (__file__ ).parent / "static" / "link.js" ).read_text (encoding = "utf-8" )
4141
4242
43- def link (attributes : dict [str , Any ], * children : Any ) -> Component :
43+ def link (attributes : dict [str , Any ], * children : Any , key : Key | None = None ) -> Component :
4444 """
4545 Create a link with the given attributes and children.
4646
@@ -51,7 +51,7 @@ def link(attributes: dict[str, Any], *children: Any) -> Component:
5151 Returns:
5252 A link component with the specified attributes and children.
5353 """
54- return _link (attributes , * children )
54+ return _link (attributes , * children , key = key )
5555
5656
5757@component
@@ -132,7 +132,7 @@ def route(path: str, element: Any | None, *routes: Route) -> Route:
132132 return Route (path , element , routes )
133133
134134
135- def navigate (to : str , replace : bool = False ) -> Component :
135+ def navigate (to : str , replace : bool = False , key : Key | None = None ) -> Component :
136136 """
137137 Navigate to a specified URL.
138138
@@ -146,7 +146,7 @@ def navigate(to: str, replace: bool = False) -> Component:
146146 Returns:
147147 The component responsible for navigation.
148148 """
149- return _navigate (to , replace )
149+ return _navigate (to , replace , key = key )
150150
151151
152152@component
0 commit comments