Skip to content
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

componentDidUpdate is not called when a component calls setState() #1755

Closed
ajbogh opened this issue Aug 15, 2018 · 4 comments
Closed

componentDidUpdate is not called when a component calls setState() #1755

ajbogh opened this issue Aug 15, 2018 · 4 comments

Comments

@ajbogh
Copy link

ajbogh commented Aug 15, 2018

When a component uses setState() the componentDidUpdate call is supposed to fire and any code within it is supposed to be executed. Enzyme 3.4.1 does not execute the cDU code when setState() is called within the component.

To Reproduce
Steps to reproduce the behavior:

  1. Make sure enzyme 3.4.1 is installed: npm install enzyme@3.4.1
  2. Create a component that takes a callback prop, contains the componentDidUpdate method and another method that calls setState(). The cDU method should execute the callback when it's fired.
  3. Create a test which spies on the callback prop and executes the component method which calls setState()
  4. Notice that the cDU is not executed

Expected behavior
cDU should be executed when a component's setState is called.

Desktop (please complete the following information):

  • OS: iOS
  • Browser Node
  • Version 8.11.3

Additional context
#1452
#1742 (comment)

Code Sample

https://github.com/ajbogh/enzyme-setstate-bug

@koba04
Copy link
Contributor

koba04 commented Aug 16, 2018

@ajbogh #1742 isn't included v3.4.1 so please wait for the next release!

@ajbogh
Copy link
Author

ajbogh commented Aug 16, 2018

Oh. Thanks @koba04. My mistake. I'll check back when the release happens.

@ljharb
Copy link
Member

ljharb commented Aug 16, 2018

v3.4.2 is released; I'll reopen this if the issue isn't addressed.

@ljharb ljharb closed this as completed Aug 16, 2018
@ajbogh
Copy link
Author

ajbogh commented Aug 16, 2018

v3.4.2 fixed the issue! Thanks for the great work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants