-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Maintain key
compatibility with React (prepend .$
)
#3403
Comments
I wonder whether this is something we need to handle in render to string or when does this occur? Does this happen during csr or? Just trying to wrap my head around the meat of the issue, the goal would be to have a minimal amount of size but compatability is important to us for /compat 😃 |
For the project I encountered this in, it happens during SSR and remains during CSR of course. Here's the NextJS code looking for This is Preact's current passthrough for Lines 268 to 279 in 4f08ae4
Unless there are assumptions within Preact on key remaining the same as what was provided initially, I believe we could just do children.key = '.$' + children.key (with existence checks) before pushing.
EDIT: React claims keys are escaped to ensure safety for |
I find the check a bit odd 😅 I guess it would be better to add this here but essentially I find the check for |
Assuming you meant Others who are using |
Is there any update on this? Meta tags are currently still duplicated when using Nextjs with preact/compat. |
Prepending Example: <link rel='canonical' key=".$canonical" href={`${hostname}${canonicalPath}`} /> |
Describe the feature you'd love to see
Copy-pasting my findings from vercel/next.js#32944 (comment): React "escapes" keys by prepending
.$
while remappingchildren
into an array. Relevant lines of code (facebook/react@a724a3b5/.../ReactChildren.js):React docs:
preact/compat passes
Children.toArray
over totoChildArray
from the same layer, but doesn't bother adjusting keys. This leads to situations like the above linked issue. NextJS features auto-dedupe based onkey
s, which is great for cross-pagemeta
tags that need updation:Since preact/compat is meant to maintain compatibility with React "as much as possible", could this be implemented? It doesn't exactly fit in with project goals, but it doesn't go against it either.
If approved, I'd be happy to create a PR.
Additional context (optional)
preactjs/next-plugin-preact#51 is the same issue; not sure if it's the correct repo though. Which is why I've created this one.
The text was updated successfully, but these errors were encountered: