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

Unexpected regexp behavior in useThrottledEffect demo #1482

Open
alev000 opened this issue Jan 3, 2024 · 1 comment
Open

Unexpected regexp behavior in useThrottledEffect demo #1482

alev000 opened this issue Jan 3, 2024 · 1 comment

Comments

@alev000
Copy link

alev000 commented Jan 3, 2024

This demo for useThrottledEffect exhibits some strange behavior. To reproduce, try slowly entering the string a1aaaaaa into the text box, and you'll see the status toggle repeatedly between "no digits" and "has digits".

I think the regexp in this line should drop the "global" flag. From these docs:

JavaScript RegExp objects are stateful when they have the global or sticky flags set (e.g., /foo/g or /foo/y). They store a lastIndex from the previous match.

@alev000
Copy link
Author

alev000 commented Jan 3, 2024

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

No branches or pull requests

1 participant