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

fix: keep hooks index with useEffect #4016

Merged
merged 2 commits into from
May 20, 2023

Conversation

1o1w1
Copy link
Contributor

@1o1w1 1o1w1 commented May 19, 2023

Fixes #4015

I have submitted an issue.

Describe the bug

CurrentIndex may become stale when the useEffect callback function is called in options._render

To Reproduce

https://github.com/1o1w1/preact/blob/hooks-order-issue-reproduction/demo/index.js

Steps to reproduce the behavior:

  1. open demo in browser
  2. Click the "Count" string on the page
  3. See "Count: binggo!!" on the page

Expected behavior
expect to see “Count: 2”

@1o1w1
Copy link
Contributor Author

1o1w1 commented May 19, 2023

Let me know if there's anything you'd like me to change/update/improve. 🙏

Copy link
Member

@JoviDeCroock JoviDeCroock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good find thank you!

@coveralls
Copy link

Coverage Status

Coverage: 99.705% (+0.0009%) from 99.704% when pulling efa4a80 on 1o1w1:fix-hooks-order-issue into f5af720 on preactjs:master.

@JoviDeCroock JoviDeCroock merged commit 0b881e9 into preactjs:master May 20, 2023
@JoviDeCroock JoviDeCroock mentioned this pull request May 20, 2023
JoviDeCroock added a commit that referenced this pull request Jan 24, 2024
JoviDeCroock added a commit that referenced this pull request Jan 24, 2024
* backport #4016

* backport #3996

* backport #4017

* backport #4019

* backport #4020

* backport #4026

* backport #4028
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

Successfully merging this pull request may close these issues.

hooks index is incorrect with useEffect
3 participants