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

Correctly handle arrow function expression arguments when used with non-'on' properties #1672

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

Conversation

STRd6
Copy link
Contributor

@STRd6 STRd6 commented Jan 30, 2025

Description

Handle arrow function expressions for non-on properties. See https://mitosis.builder.io/playground/?code=KYDwDg9gTgLgBAE2AMwIYFcA29noHYDGMAlhHnALICeAwhALaR7B4wAUAlHAN4BQvcOFGAx0UcmwGDpAHmJ4w6GFOlwYwAM4wAvNzaoANHABGRgl20A%2BOKjgBqE%2FbgEAviukB6S1I4BuXi5AA%3D%3D%3D for an example of how it is currently broken.

  • format the codebase: from the root, run yarn fmt:prettier.
  • update all snapshots (in core & CLI): from the root, run yarn test:update
  • add Changeset entry: from the root, run yarn g:changeset and follow the CLI instructions. Alternatively, use the Changeset Github Bot to create the file.

@STRd6 STRd6 requested a review from samijaber as a code owner January 30, 2025 19:21
Copy link

changeset-bot bot commented Jan 30, 2025

🦋 Changeset detected

Latest commit: a26ce0a

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

This PR includes changesets to release 2 packages
Name Type
@builder.io/mitosis Patch
@builder.io/mitosis-cli 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 Jan 30, 2025

View your CI Pipeline Execution ↗ for commit a26ce0a.

Command Status Duration Result
nx run-many --target test ✅ Succeeded 4m 26s View ↗
nx e2e @builder.io/e2e-app ✅ Succeeded 1m 11s View ↗
nx build @builder.io/mitosis-site ✅ Succeeded 1s View ↗
nx run-many --target build --exclude @builder.i... ✅ Succeeded 1s View ↗

☁️ Nx Cloud last updated this comment at 2025-01-30 19:34:50 UTC

Copy link

cloudflare-workers-and-pages bot commented Jan 30, 2025

Deploying mitosis with  Cloudflare Pages  Cloudflare Pages

Latest commit: a26ce0a
Status: ✅  Deploy successful!
Preview URL: https://49c19f1c.mitosis-9uh.pages.dev
Branch Preview URL: https://allow-arrow-function-express.mitosis-9uh.pages.dev

View logs

@STRd6 STRd6 enabled auto-merge (squash) January 30, 2025 19:50
Copy link
Contributor

@samijaber samijaber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! just need to tweak the changeset format

'@builder.io/mitosis': patch
---

Fix arrow function expressions in non-on properties
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -282,11 +282,9 @@ export const jsxElementToJson = (
if (types.isStringLiteral(expression)) {
// <Foo myProp={"hello"} />
memo.properties[key] = expression.value;
} else if (types.isArrowFunctionExpression(expression)) {
} else if (key.startsWith('on') && types.isArrowFunctionExpression(expression)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so the fix for non-on properties is to not have them run this code for isArrowFunctionExpression?

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.

3 participants