Skip to content

Commit

Permalink
use_location support
Browse files Browse the repository at this point in the history
  • Loading branch information
Archmonger committed Sep 15, 2023
1 parent d1fe1c4 commit 48418fe
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/reactpy_django/templatetags/reactpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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,
),
)
Expand Down

0 comments on commit 48418fe

Please sign in to comment.