From 9f998f4ab3dff1099ac9918ff302aa992ffe9daa Mon Sep 17 00:00:00 2001 From: Jakub Adamczyk Date: Thu, 18 Apr 2019 15:42:55 +0200 Subject: [PATCH] change to invariant --- src/core/AnimatedAlways.js | 10 +++++----- src/core/AnimatedSet.js | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/core/AnimatedAlways.js b/src/core/AnimatedAlways.js index ab95d9d..71f1d8d 100644 --- a/src/core/AnimatedAlways.js +++ b/src/core/AnimatedAlways.js @@ -1,14 +1,14 @@ import AnimatedNode from './AnimatedNode'; +import invariant from 'fbjs/lib/invariant'; export default class AnimatedAlways extends AnimatedNode { _what; constructor(what) { - if (!(what instanceof AnimatedNode)) { - throw new Error( - `Animated.always parameter should be of type AnimatedNode but got ${typeof what}` - ); - } + invariant( + what instanceof AnimatedNode, + `Animated.set target should be of type AnimatedNode but got ${typeof what}` + ); super({ type: 'always', what: what.__nodeID }, [what]); this._what = what; } diff --git a/src/core/AnimatedSet.js b/src/core/AnimatedSet.js index 79e9c97..d0ae1b3 100644 --- a/src/core/AnimatedSet.js +++ b/src/core/AnimatedSet.js @@ -1,16 +1,16 @@ import AnimatedNode from './AnimatedNode'; import { val } from '../utils'; +import invariant from 'fbjs/lib/invariant'; export default class AnimatedSet extends AnimatedNode { _what; _value; constructor(what, value) { - if (!(what instanceof AnimatedNode)) { - throw new Error( - `Animated.set target should be of type AnimatedNode but got ${typeof what}` - ); - } + invariant( + what instanceof AnimatedNode, + `Animated.set target should be of type AnimatedNode but got ${typeof what}` + ); super({ type: 'set', what: what.__nodeID, value: value.__nodeID }, [value]); this._what = what; this._value = value;