-
-
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
setProps overwrites props when component is shallow mounted #1654
Comments
Hi @omarjackman I think it's related to #1628 |
enzyme v3.3.0 |
@ljharb @omarjackman I thought it was connected to this issue #1628, but after checking my PR I realized that I was wrong. It is more similar to this one #1599. Shallow wrapper sets props from |
is there a way to actually set fresh props without merging? I have a use case for that to avoid unnecessary mounting |
Describe the bug
When a component is shallow mounted the
setProps
function seems to be replacing(instead of merging) the props internally for the component when no change is made. Subsequent calls tosetProps
that do yield a change causes theprevProps
argument ofcomponentDidUpdate
to contain an incorrect value.To Reproduce
The following example code throws an error showing that the previous props passed to
componentDidUpdate
is incorrect.I was only able to reproduce this when using a custom
shouldComponentUpdate
implementation that usesisEqual
to check the propsExpected behavior
In the example above I expected
prevProps
to equalinstead it equals
Additional context
My workaround is to use
mount
instead ofshallow
The text was updated successfully, but these errors were encountered: