From a3aaa471eca58b31597b9a0669f7ade385ccb175 Mon Sep 17 00:00:00 2001 From: Luna Wei Date: Tue, 10 Mar 2020 17:59:53 -0700 Subject: [PATCH] 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 --- Libraries/Animated/src/nodes/AnimatedValue.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Libraries/Animated/src/nodes/AnimatedValue.js b/Libraries/Animated/src/nodes/AnimatedValue.js index 13f5d8ab87..7306fc77b9 100644 --- a/Libraries/Animated/src/nodes/AnimatedValue.js +++ b/Libraries/Animated/src/nodes/AnimatedValue.js @@ -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; @@ -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;