fix(useTransition): fix regression with non-linear transition functions #2973
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before submitting the PR, please make sure you do the following
fixes #123
).Description
There was a regression with
useTransition
during the change fromunref
→toValue
. Non-linear custom easing functions were returningNaN
. This is due totoValue
first doing it's own function check, and returning the output of that function rather than the function itself.This didn't break linear transitions because those are essentially just identity-functions, which return
undefined
when no input is provided. This led to using the right side oftoValue(...) ?? linear
, and therefor the default linear transition. With non-linear transitions however, that numeric input is necessary, and without it we end up doing arithmetic onundefined
, which leads to theNaN
.I've fixed this with a manual function check, and included a test to cover this situation. Alternatively, we could use the default
unref
function here to avoid the redundant type checking.Additional context
🤖 Generated by Copilot at fe1ec45
This pull request adds support for custom easing functions to the
useTransition
function. It modifies theexecuteTransition
function to handle function parameters and adds a test case to verify the functionality.🤖 Generated by Copilot at fe1ec45
useTransition
(link, link)easeInQuad
function (link)