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

forwardRef fails on patchFunctionalComponent #1436

Closed
ChrisKuBa opened this issue Jan 16, 2019 · 2 comments
Closed

forwardRef fails on patchFunctionalComponent #1436

ChrisKuBa opened this issue Jan 16, 2019 · 2 comments
Labels

Comments

@ChrisKuBa
Copy link
Contributor

Hi,

when patching a function component inferno dosn't differ between function component with and without forwardrefs, like on mounting.

function mountFunctionalComponent$2(vNode, parentDOM, context, isSVG, nextNode, lifecycle) {
  ...
  var ref = vNode.ref;
  var input = handleComponentInput$2(vNode.flags & 32768
  /* ForwardRef */
  ? type(props, ref, context) : type(props, context));
 ...
}
function patchFunctionalComponent(lastVNode, nextVNode, parentDOM, context, isSVG, nextNode, lifecycle) {
  ...
  if (shouldUpdate !== false) {
    if (nextHooksDefined && isFunction(nextRef.onComponentWillUpdate)) {
      nextRef.onComponentWillUpdate(lastProps, nextProps);
    }

    var nextInput = handleComponentInput(nextVNode.type(nextProps, context));
    patch(lastInput, nextInput, parentDOM, context, isSVG, nextNode, lifecycle);
  ...
}

So the call to nextVNode.type will be without ref. At the end ref is context, lastVNode.ref !== nextVNode.ref and the ref will be nulled.

   ...
  var nextRef = nextVNode.ref;
  var lastRef = lastVNode.ref;

  if (lastRef !== nextRef) {
    unmountRef$2(lastRef);
    mountRef$2(nextRef, dom, lifecycle);
  }
   ...

Thx

@Havunen
Copy link
Member

Havunen commented Jan 17, 2019

Hi @chrkulbe

Thanks for reporting this issue, I will have a look into it when I have some free time :)

@Havunen Havunen added bug and removed bug to verify labels Jan 21, 2019
@Havunen
Copy link
Member

Havunen commented Jan 21, 2019

Fixed in master

@Havunen Havunen closed this as completed Jan 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants