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

useState re-renders the function with a timeout #14877

Closed
KirilVelichkov opened this issue Feb 18, 2019 · 2 comments
Closed

useState re-renders the function with a timeout #14877

KirilVelichkov opened this issue Feb 18, 2019 · 2 comments

Comments

@KirilVelichkov
Copy link

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

What is the current behavior?
useState re-renders the function with a short timeout

I have made a very small and simple TODO component with both React Class and React Function component. I wrote a few test to each (NOTE: tests are exactly the same for the class component and function component)
When running the tests for the function component it looks like that the render of the function is called with a short timeout(The function component uses useState in it)
A working example can be found in this repo: https://github.com/KirilVelichkov/react-hooks-bug
To see the bug go to todo.test.js and un-comment line 62. To see how i got it fixed un-comment the below lines.

This is reproducible on both Windows 10 and macOS High Sierra 10.13.6

Node version - 11.0.0
NPM version - 6.4.1

@gaearon
Copy link
Collaborator

gaearon commented Feb 18, 2019

This is the same issue as #14840.

It's specifically about the shallow renderer.

@gaearon gaearon closed this as completed Feb 18, 2019
@gaearon
Copy link
Collaborator

gaearon commented Mar 22, 2019

Fixed in 16.8.5.

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

2 participants