Skip to content

Functional component ref and Transition issueΒ #1050

@michaeltintiuc

Description

@michaeltintiuc

Version

3.0.0-beta.4

Reproduction link

https://github.com/michaeltintiuc/ionic-vue-3-example

Steps to reproduce

export const Foo: FunctionalComponent = props => {
  const myRef = ref();
  return h(
    'div',
    { ...props, ref: myRef },
    h(View, { name, route }, (...opts: any) => {
      const { Component, props: componentProps } = opts[0];
      return h(
        Transition,
        {
          css: false,
          mode: 'in-out',
          ...transitionHooks
        },
        () => [h(Component, componentProps)]
      );
    })
  );
}

What is expected?

With previous beta versions this was working as an equivalent to:

<div>
    <RouterView v-slot="{ Component, props }">
      <Transition mode="in-out" :appear="true">
        <component :is="Component" v-bind="props" />
      </Transition>
    </RouterView>
</div>

What is actually happening?

With Beta 4 I am getting the following warning:
Missing ref owner context. ref cannot be used on hoisted vnodes. A vnode with ref must be created inside the render function.

And the following error:
Cannot read property 'subTree' of null

I was able to trace the error to https://github.com/vuejs/vue-next/blob/master/packages/runtime-core/src/components/BaseTransition.ts#L166

getCurrentInstance returns null in BaseTransition as well as in the functional component render function.

I'm not sure if this is a bug or if it was working by accident.
FWIW the template works fine, I'm looking for a translation to a render function.


Minimal reproduction allows to see the bug, yet the the file displaying the issue is within my library here:
https://github.com/ModusCreateOrg/ionic-vue/blob/dev/src/components/router-outlet/index.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions