Skip to content
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

fix[gen2-sdks]: add keys for Fragment inside Accordion JSX loop #3725

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

oxcabe
Copy link

@oxcabe oxcabe commented Nov 7, 2024

Description

This PR adds the key attribute inside the Accordion component. This attribute is required by React's use of loops in JSX code, and will throw an error when the top-level children in a loop are missing this attribute.

From the TypeScript handbook on JSX.IntrinsicAttributes:

Additionally, the JSX.IntrinsicAttributes interface can be used to specify extra properties used by the JSX framework which are not generally used by the components’ props or arguments - for instance key in React. Specializing further, the generic JSX.IntrinsicClassAttributes type may also be used to specify the same kind of extra attributes just for class components (and not Function Components). In this type, the generic parameter corresponds to the class instance type. In React, this is used to allow the ref attribute of type Ref. Generally speaking, all of the properties on these interfaces should be optional, unless you intend that users of your JSX framework need to provide some attribute on every tag.

Additional concerns

Although this is more a situation exclusively about Mitosis, I wanted to, at least, mention it here.

I'd argue that the key attribute, being intrinsic to React's use of JSX, should be managed accordingly inside Mitosis heuristics in order to avoid polluting the Mitosis JSX markup with references to specific transpiler back-ends. Moreover, how could we do the same we're doing in this commit if we were to use Sveltosis instead?

For this reason, I want to propose considering this a temporary fix and solve the problem in the right context, which would be Mitosis handling of key attributes in loops.

@oxcabe oxcabe requested review from samijaber and a team as code owners November 7, 2024 11:56
Copy link

changeset-bot bot commented Nov 7, 2024

🦋 Changeset detected

Latest commit: 27f6e9b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
@builder.io/sdk-angular Patch
@builder.io/sdk-qwik Patch
@builder.io/sdk-react Patch
@builder.io/sdk-react-native Patch
@builder.io/sdk-solid Patch
@builder.io/sdk-svelte Patch
@builder.io/sdk-vue Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

nx-cloud bot commented Nov 7, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 27f6e9b. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


🟥 Failed Commands
nx test @snippet/angular-ssr
nx test @snippet/angular
nx test @snippet/react
nx test @e2e/react-sdk-next-pages
nx test @e2e/solid-start
nx test @e2e/solid
nx test @snippet/solid

Sent with 💌 from NxCloud.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant