Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.7k
fix(useTransition): prevent runtime error when source is not number o…#4815
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Actually, I think throwing an error here is expected because this will remind you of the reason. From what I've seen in thedocumentation, the first argument to According to your description, you defined the data type wrong and need to fix it. |
@9romise Thank you for your reply — I completely agree with your point. You're right that my commit could hide the real issue and make debugging harder. But I noticed that other functions like If you think it makes sense, I’d be happy to revise my code to improve the robustness of |
…r number[]
Before submitting the PR, please make sure you do the following
fixes #123
).Description
Fixes#4814
This PR fixes a potential runtime error in useTransition when the source is not a number or array of numbers.
Currently, passing a string or other unsupported type as source will result in:
TypeError: v.map is not a function
This can crash the application or prevent rendering when unexpected types are passed in.
Additional context
The fix introduces a simple type check to ensure the value is either:
a single number, or
an array (e.g., number[] or MaybeRef[])
Otherwise, it falls back to a safe default (0), avoiding the .map() call on unsupported types.