Skip to content

[react-strict-animated] Fix incorrect error message for invalid mass in SpringAnimation#499

Open
adityasingh2400 wants to merge 1 commit into
react:mainfrom
adityasingh2400:fix-spring-mass-error-message
Open

[react-strict-animated] Fix incorrect error message for invalid mass in SpringAnimation#499
adityasingh2400 wants to merge 1 commit into
react:mainfrom
adityasingh2400:fix-spring-mass-error-message

Conversation

@adityasingh2400

Copy link
Copy Markdown

Summary

The mass validation in the SpringAnimation constructor throws the wrong error message. It reports a damping problem when an invalid mass is supplied, because the message was copy-pasted from the preceding damping check.

if (this.#damping <= 0) {
  throw new Error('Damping value must be greater than 0');
}
if (this.#mass <= 0) {
  throw new Error('Damping value must be greater than 0'); // should be Mass
}

A user passing mass: 0 (or a negative mass) gets told their damping value is wrong, which points them at the wrong config field. React Native's equivalent SpringAnimation throws 'Mass value must be greater than 0' here.

Fix

Use the correct message for the mass check.

Test

Added SpringAnimation-test.js covering all three constructor validations (stiffness, damping, mass). The mass case fails on main (asserts 'Mass value must be greater than 0') and passes with the fix.

flow check and eslint are clean.


Reopening this. I closed it by accident during a bulk cleanup of my stale forks and cannot reopen the original because the fork was deleted, so this is the same branch restored. Sorry for the noise @MoOx.

…in SpringAnimation

The mass validation in the SpringAnimation constructor threw 'Damping value
must be greater than 0', a copy-paste of the preceding damping check. It now
reports 'Mass value must be greater than 0', matching the field being
validated (and the equivalent check in React Native's SpringAnimation).
@github-actions

Copy link
Copy Markdown

workflow: benchmarks/perf (native)

Comparison of performance test results, measured in operations per second. Larger is better.

Results Base Patch Ratio
css.create
· small 1,177,102 1,165,316 0.99 -
· small with units 518,029 522,422 1.01 +
· small with variables 699,492 698,237 1.00 -
· several small 375,307 371,936 0.99 -
· large 219,648 215,158 0.98 -
· large with polyfills 162,353 162,533 1.00 +
· complex 112,357 113,791 1.01 +
· unsupported 222,705 222,039 1.00 -
css.createTheme
· simple theme 245,202 245,589 1.00 +
· polyfill theme 232,172 232,003 1.00 -

@github-actions

Copy link
Copy Markdown

workflow: benchmarks/size

Comparison of minified (terser) and compressed (brotli) size results, measured in bytes. Smaller is better.

Results Base Patch Ratio
react-strict-dom/dist/web/index.js
· compressed 3,251 3,251 1.00
· minified 10,375 10,375 1.00
react-strict-dom/dist/web/runtime.js
· compressed 1,645 1,645 1.00
· minified 4,131 4,131 1.00
react-strict-dom/dist/native/index.js
· compressed 16,618 16,705 1.01 +
· minified 64,626 64,818 1.00 +
react-strict-animated/dist/web/index.js
· compressed 6,861 6,855 1.00 -
· minified 23,486 23,483 1.00 -
react-strict-animated/dist/native/index.js
· compressed 797 797 1.00
· minified 2,518 2,518 1.00

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant