Skip to content

A nested ForwardRef is not recognized as a valid component by shallow dive() #1830

@uxtechie

Description

@uxtechie

Describe the bug
A nested ForwardRef is not recognized as a valid component when I do shallow dive() to it.

To Reproduce
Steps to reproduce the behavior:

  1. Sample code:
  import * as React from "react";
  import { shallow } from 'enzyme';

  const Component = () => <div/>
  const HOCOne = (WrappedComponent) => React.forwardRef(() => <WrappedComponent/>)
  const HOCTwo = (WrappedComponent) => React.forwardRef(() => <WrappedComponent/>)
  const WithNestedForwarRefComponent = HOCTwo(HOCOne(Component)))
  
  const vDomWrapper = shallow(<WithNestedForwarRefComponent/>);
  
  1. Then debug() and dive() vDomWrapper:
  vDomWrapper.debug()
  vDomWrapper.dive()
  1. Debug output:
    <ForwardRef(HOCOne(Component)) />
  2. See dive() error:
    TypeError: ShallowWrapper::dive() can only be called on components

Expected behavior
A ForwardRef component must be recognized as such and it must be possible to do dive () on it.

Desktop:

  • OS: Ubuntu 18.04
  • Node: 8.11.3
  • Enzyme: 3.6.0
  • React: 16.5.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions