diff --git a/src/reactpy_django/templatetags/reactpy.py b/src/reactpy_django/templatetags/reactpy.py index 396ec398..7f0a64d8 100644 --- a/src/reactpy_django/templatetags/reactpy.py +++ b/src/reactpy_django/templatetags/reactpy.py @@ -9,7 +9,7 @@ from django.http import HttpRequest from django.urls import NoReverseMatch, reverse from reactpy.backend.hooks import ConnectionContext -from reactpy.backend.types import Connection +from reactpy.backend.types import Connection, Location from reactpy.core.types import ComponentConstructor from reactpy.utils import vdom_to_html @@ -174,12 +174,15 @@ def validate_host(host: str): def preload_component( user_component: ComponentConstructor, args, kwargs, request: HttpRequest ): + search = request.GET.urlencode() with SyncLayout( ConnectionContext( user_component(*args, **kwargs), value=Connection( scope=getattr(request, "scope", {}), - location=request.path, + location=Location( + pathname=request.path, search=f"?{search}" if search else "" + ), carrier=request, ), )