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
This commit is contained in:
Luna Wei 2020-03-10 17:59:53 -07:00 коммит произвёл Facebook Github Bot
Родитель 0d6d58656a
Коммит a3aaa471ec
1 изменённых файлов: 4 добавлений и 1 удалений

Просмотреть файл

@ -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;