web
web copied to clipboard
Unexpected regexp behavior in useThrottledEffect demo
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.
Same for the useDebouncedEffect demo
Relevant code search link: https://github.com/search?q=repo%3Areact-hookz%2Fweb+%2F%5C%2Fg%5Cb%2F&type=code