-
Notifications
You must be signed in to change notification settings - Fork 666
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Partial rendering of elements is out of order #1950
Comments
Took a closer look and the issue stems from there being two We should throw a warning or an error when a partial with the same name is detected. |
I think then I misunderstood the API and the However if I remove it still does not work. The form handler is updating the params, it is the same page. I think I am not getting it. |
Your app renders two Partials with the same name. Inside <Partial name="foo">
<Partial name="foo">...</Partial>
</Partial> In your case you don't need the partial in export default async function Home(
// ...snip
return (
- <Partial name="main">
+ <>
{search === "" && (
<h2 class="my-4 text-center text-2xl font-bold leading-9 tracking-tight text-gray-200">
Featured products
</h2>
)}
<div class="m-4 p-4 border-blue-300 border-2 rounded-xl ">
{products && <ProductList products={products}></ProductList>}
</div>
- </Partial>
+ </>
);
} |
I guess you meant Thanks in advance for your time |
oh sorry yeah you're right, meant |
@SFToro Apply this patch to your project to resolve the issue. diff --git a/islands/SearchForm.tsx b/islands/SearchForm.tsx
index 4338824..01ce92f 100644
--- a/islands/SearchForm.tsx
+++ b/islands/SearchForm.tsx
@@ -22,7 +22,7 @@ export default function SearchForm() {
class="space-y-6"
id="search-form"
action="/products"
- method="POST"
+ method="GET"
onSubmit={handleSubmit}
>
<div>
diff --git a/routes/index.tsx b/routes/index.tsx
index 90fe802..bf7867c 100644
--- a/routes/index.tsx
+++ b/routes/index.tsx
@@ -19,7 +19,7 @@ export default async function Home(
}
return (
- <Partial name="main">
+ <>
{search === "" && (
<h2 class="my-4 text-center text-2xl font-bold leading-9 tracking-tight text-gray-200">
Featured products
@@ -28,6 +28,6 @@ export default async function Home(
<div class="m-4 p-4 border-blue-300 border-2 rounded-xl ">
{products && <ProductList products={products}></ProductList>}
</div>
- </Partial>
+ </>
);
} |
Hi again,
Anyway what I am trying to say is that i applied such patch in the layout and i am still getting the same behaviour <>
{search === "" && (
<h2 class="my-4 text-center text-2xl font-bold leading-9 tracking-tight text-gray-200">
Featured products
</h2>
)}
<div class="m-4 p-4 border-blue-300 border-2 rounded-xl ">
{products && <ProductList products={products}></ProductList>}
</div>
</> <>
<header class="px-4 py-8 mx-auto bg-[#86efac]">
<div class="max-w-screen-md mx-auto flex flex-col items-center justify-center">
<a href="/">
<img
class="mt-4"
src="/logo.svg"
width="64"
height="64"
alt="the Fresh logo: a sliced lemon dripping with juice"
/>
</a>
<SearchForm></SearchForm>
</div>
</header>
<main>
<Partial name="main">
<Component />
</Partial>
</main>
</> still same behaviour |
@SFToro |
simplescreenrecorder-2023-10-18_20.21.00.webm |
Just leaving some debugging notes for myself here:
|
This is resolved by upgrading to Preact |
I have this page component. Based on the query params the h2 should be displayed or not. I am using a form to update the query params. If i do a search and I hit the back button or click a link to come back, the h2 heading is rendered AFTER.
Here is the video:
simplescreenrecorder-2023-10-17_14.29.13.webm
I added
f-client-nav
to the body tag. Created a_layout.tsx
and using the page function component as a whole as a partial.Here is the link to code sand box: https://codesandbox.io/p/sandbox/compassionate-yalow-f3r7fr and this is the running example: https://f3r7fr-8000.csb.app/
The text was updated successfully, but these errors were encountered: