Skip to content

Commit

Permalink
Add JS error to AnimatedValue constructor
Browse files Browse the repository at this point in the history
Summary:
Changelog: [Internal]
Add one more error around AnimatedValue.js returning an undefined value for "value" property.

Since this error happens in construction of the animated node, it makes sense that the constructor could be passed an undefined value?

Reviewed By: zackargyle

Differential Revision: D20354532

fbshipit-source-id: ba35172cd91977c48c849a2b1e27596c4dd8b4d4
  • Loading branch information
Luna Wei authored and facebook-github-bot committed Mar 11, 2020
1 parent 0d6d586 commit a3aaa47
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Libraries/Animated/src/nodes/AnimatedValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ class AnimatedValue extends AnimatedWithChildren {

constructor(value: number) {
super();
if (typeof value !== 'number') {
throw new Error('AnimatedValue: Attempting to set value to undefined');
}
this._startingValue = this._value = value;
this._offset = 0;
this._animation = null;
Expand Down Expand Up @@ -240,7 +243,7 @@ class AnimatedValue extends AnimatedWithChildren {

_updateValue(value: number, flush: boolean): void {
if (value === undefined) {
throw new Error('Attempting to set value to undefined');
throw new Error('AnimatedValue: Attempting to set value to undefined');
}

this._value = value;
Expand Down

0 comments on commit a3aaa47

Please sign in to comment.