BuilderIO/mitosis

Problems with vue onUpdated event

wabi-habi opened this issue · 1 comments

I am interested in helping provide a fix!

Yes

Which generators are impacted?

  • All
  • Angular
  • HTML
  • Preact
  • Qwik
  • React
  • React-Native
  • Solid
  • Stencil
  • Svelte
  • Vue
  • Web components

Reproduction case

Additional information is available in full code

Expected Behaviour

mitosis

image

vue

image

Actual Behaviour

vue

image

Additional Information

Full Code:

import { onUpdate, useStore } from '@builder.io/mitosis'

export default function MyComponent(props) {
  const state = useStore({
    scale: 1
  })

  onUpdate(() => {
    if (!props.src && !props.icon) return

    state.scale = Math.random() * 10
  })

  return <div>{state.scale}</div>
}

@wabi-habi thanks for filing. We're missing the { and } braces in this line:

${onUpdateWithoutDeps?.map((hook) => `onUpdated(() => ${hook.code})`).join('\n') || ''}

If you wanna contribute a fix that'd be awesome! 🙏🏽

  • make the fix
  • run yarn snapupdate in packages/core to update snapshots
  • run yarn fm:prettier in the root of the codebase to format your changes