-
Notifications
You must be signed in to change notification settings - Fork 542
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
Mitosis does not convert optional callbacks in angular to use @Output and event emitter. #918
Open
1 of 11 tasks
Labels
bug
Something isn't working
Comments
cadamsdev
changed the title
Mitosis not converting callbacks into @Output events in angular
Mitosis does not convert callbacks in angular to use @Output and event emitter.
Nov 16, 2022
export default function MyComponent(props) {
function handleClickButton() {
props.onClose?.(); // change to `props.onClose()` works
}
return (
<button onClick={() => handleClickButton()}>click me</button>
);
}
|
That does work, but what happens if the callback is optional? If I do this I'll have lint issues. We'd have to do something like this (which works) export default function MyComponent(props) {
function handleClickButton() {
if (props.onClose) {
props.onClose();
}
}
return (
<button onClick={() => handleClickButton()}>click me</button>
);
} Though mitosis should also support this way as well. export default function MyComponent(props) {
function handleClickButton() {
props.onClose?.();
}
return (
<button onClick={() => handleClickButton()}>click me</button>
);
} |
cadamsdev
changed the title
Mitosis does not convert callbacks in angular to use @Output and event emitter.
Mitosis does not convert optional callbacks in angular to use @Output and event emitter.
Nov 17, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am interested in helping provide a fix!
Yes
Which generators are impacted?
Reproduction case
https://mitosis.builder.io/?outputTab=IYOw5grgNsBOQ%3D%3D%3D&code=KYDwDg9gTgLgBAE2AMwIYFcA29noHYDGMAlhHnALICeAwhALaR7B4wAUYUEYAzgJRwA3gCg4cXIRJk4AC1R4EmYDUzECAawBC6GDDJsBIsWM7ceAOjIqIPYAH5zBgNxxRcAL7C3UYDHRRyNjcxAB4AIx09citVDQBeQQM4OIA%2BWXlFZVitSP0%2BdxSCbLh6YBCAegjdMhS3PidhTyA%3D%3D%3D
Expected Behaviour
mitosis
should be converted into this angular code
Actual Behaviour
mitosis
angular
Additional Information
Angular output
see here
Stackblitz
see here
The text was updated successfully, but these errors were encountered: