-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
wrapper is not updated when using conditional rendering in v3 #1163
Comments
What version of React are you using? |
Here is the full dependencies https://github.com/yesmeck/enzyme-set-props-bug/blob/master/package.json |
I can confirm this behavior with |
Same issue for me, update is not working for React 16. |
I investigated it and found the source of the bug: At the first render, vnode.memoizedProps is the source of truth. That was it is named Should we alternate the node at each render? @gaearon @sebmarkbage @acdlite |
Having the same issue with react adapter ^15.5.0. Edit: |
Can confirm, having the same issue with React 16 and Enzyme 3, .html() yields correct result but using .debug() or trying to .find('selector') will yield no result after conditional rendering. |
It's not possible to get the "current" subtree from any particular node. Meaning that this is not possible to implement this as a shortcut: The only way to get the current tree is to find the root and scan the tree, walking from the root. You shouldn't ever need to touch the (The reason for this is because we don't actually mutate every node in the commit phase. We only swap the root pointer. That's why that's the only pointer that gives you the source of truth.) |
Same issue with conditional rendering based on state. Using |
Hmm. Ideally Enzyme shouldn't use any fields on |
The React 16 adapter needs to be partially rewritten. I don’t know how to read all tree from instance but I could take a look. |
@sebmarkbage thanks for the context, that's really helpful! i will work on rewriting this. hopefully we can get some cleaner code doing as you suggested. @gaearon I totally want us to get to this place. The 3.0 rewrite definitely put us in a place where this will be easier to do than before, but we still aren't quite there. I don't think you misunderstood something, I think that when I originally proposed this new architecture, I thought that we would have all of the information needed to upgrade enzyme without using any internals.... I was wrong. My goal is to eventually create a new top-level API for enzyme (tentatively called That leaves I'm hopeful we will be able to slowly move to less and less of a dependence on internals |
That makes sense, thank you for explaining! |
For |
Seems like I have the same Problem with react adapter ^15.5.0. |
Not sure, is it same issue? while I use setState to update render function, I need call shallow.update() to refresh that shallow.html() to get correct content. Some my unit test |
@HillLiu that's an intended change in v3. |
I did some heave debugging for WordPress/gutenberg#2813 and it looks like we are having the same kind of issues that are reported in this thread. I tried to add recommended |
Btw here is how we find current fiber in React itself. But you really shouldn't depend on this. If there's something we need to expose, just let us know, and we will on our side. |
Thanks @gaearon, I made a fix #1169. I think exposing an API |
@neoziro Thank you for taking the time to fix this. Do you have any idea when this change will be published on npm so we can upgrade? :) |
@hugogiraudel I think they will publish today or tomorrow |
Should this be working now? I am using [email protected] but I still get
|
@eddiemonge if you are on the latest enzyme and enzyme-adapter-react-16, please do file a new issue. |
I am facing the same issue. Has this been solved in all versions or the fix is version specific? |
@waqasiftikhar2 please file a new issue and we can figure that out. |
I can confirm this is still an issue. |
I'm having this issue as well, |
It works fine for me now with It was |
@Hedinhiervard using |
@Hedinhiervard Same for me wrapper.update() fixed it for me using [email protected], enzyme-adapter-react-16@^1.1.1, and react@^16.2.0. But wrapper.instance().forceUpdate() did not fix it for me. I was also shallow rendering my component. |
Make sure that you have |
Having this issue too, conditional rendering doesn't happen on a component I Both
|
Any update regarding this issue? I'm having exactly the same problem as @SelaO mentioned:
|
Someone who's still having an issue: please file a new issue, fill out the issue template in full, and link it back to here. Once that issue exists, anyone else should please provide any information that's different from the full issue template post from the new OP, and we'll get this solved. |
I found that when using conditional rendering, after setProps, wrapper is not updated properly.
Here is a reproduction repo https://github.com/yesmeck/enzyme-set-props-bug
The text was updated successfully, but these errors were encountered: