From 48418fe55ea557fc7b1f9c86931477cf646cfeca Mon Sep 17 00:00:00 2001 From: Archmonger <16909269+Archmonger@users.noreply.github.com> Date: Thu, 14 Sep 2023 22:58:44 -0700 Subject: [PATCH] use_location support --- src/reactpy_django/templatetags/reactpy.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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, ), )