Skip to content

react-test-renderer: the findByType method doesn't work with memo components #17301

Open
@bensampaio

Description

@bensampaio

Do you want to request a feature or report a bug?
Feature

What is the current behavior?
Whenever I try something like:

ReactTestRenderer.create(<SomeComponent />).root.findByType(SomeMemoComponent);

I get the following error: No instances found with node type: "undefined". The only way I found for this to work was to reference the type property of memo components like this:

ReactTestRenderer.create(<SomeComponent />).root.findByType(SomeMemoComponent.type);

I am fine with this solution but then flow complains that type doesn't exist so I find myself fixing this with $FlowFixMe all over the place.

What is the expected behavior?

I would expect that passing a memo component to findByType would work. Or that flow would recognize the type property of memo components. I think both should work, specially the first option.

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?

No, it never worked as far as I know.

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