Skip to content

Commit a3aaa47

Browse files
Luna Weifacebook-github-bot
authored andcommitted
Add JS error to AnimatedValue constructor
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
1 parent 0d6d586 commit a3aaa47

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Libraries/Animated/src/nodes/AnimatedValue.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ class AnimatedValue extends AnimatedWithChildren {
7777

7878
constructor(value: number) {
7979
super();
80+
if (typeof value !== 'number') {
81+
throw new Error('AnimatedValue: Attempting to set value to undefined');
82+
}
8083
this._startingValue = this._value = value;
8184
this._offset = 0;
8285
this._animation = null;
@@ -240,7 +243,7 @@ class AnimatedValue extends AnimatedWithChildren {
240243

241244
_updateValue(value: number, flush: boolean): void {
242245
if (value === undefined) {
243-
throw new Error('Attempting to set value to undefined');
246+
throw new Error('AnimatedValue: Attempting to set value to undefined');
244247
}
245248

246249
this._value = value;

0 commit comments

Comments
 (0)