Skip to content

React toTree() handling mismatches #1512

@gaearon

Description

@gaearon

Sorry for deleting the template, there are a few very specific problems I saw in the source.

  • I'm not sure how I feel about Import findCurrentFiberUsingSlowPath from react-reconciler/reflection #1399. It gives a false sense of security but in practice can still break in patch versions. I explain the reasoning in a comment there—basically, it works by accident, and if react-dom internal logic changes you'd have to fork it again anyway because you'd need to support multiple versions.

  • It seems like this call won't handle a fragment inside a root correctly. It will just skip over any but the first item. I'm not sure Enzyme API allows rendering an array or a <Fragment> as a root node but React does. (Note React's toTree() is also broken in this way—but I fixed it in Fix fragment and portal handling in toTree() facebook/react#12154.)

  • If the above is right, I suspect that this call might also not work with fragments. It is totally legitimate to put a fragment inside a portal.

I haven't had time to verify these in detail because I'm in the middle of fixing React toTree() bugs myself. But I thought it might be helpful to report for further investigation.

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