'React Native: Exception thrown while executing UI block
I'm building an iOS react-native app, and I'm currently using the react-native-swipe-card package to build "tinder" like swipe cards for my app. The app works fine however when I go to swipe a card left or right, and let it go while it's halfway off the screen I'm getting the following error:
ExceptionsManager.js:71 Exception thrown while executing UI block: -[NSNull floatValue]: unrecognized selector sent to instance 0x1075b5130
Solution 1:[1]
As @Peuchele commented, I was getting this same error, and the reason it was happening was because I passed a value into an Animated View that was undefined.
So, to clarify, make sure any values you pass into a component using an Animated.Value is not undefined.
The specific code I found at fault was:
const { value } = props;
this.state = {
translateYValue: new Animated.Value(value),
};
And props.value was undefined.
Solution 2:[2]
Or make sure the value being passed is not NAN
Solution 3:[3]
You may have to add @objc above the block in native code where you define the property.
Solution 4:[4]
I got the same error when passing an undefined to the defaultSource prop of an Image.
<Image
style={styles.imageStyle}
source={someImageSource}
defaultSource={imageFallback}
/>
When imageFallback is undefined, I got this error.
Previous answers mention passing an undefined into Animated.Value. Given that my experience is via a different component, this error probably means you're passing an undefined somewhere.
I found the culprit by commenting out varying lines of code to see what caused the error to appear. Tedious but effective.
Solution 5:[5]
This exception was thrown for me on passing a null value as the html value to WebView. The source cannot be a null.
<WebView
originWhitelist={['*']}
source={{ html: summary }}
style={[styles.webView, { height: webViewHeight }]}
scalesPageToFit={false}
useWebKit
/>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Doug Watkins |
| Solution 2 | ispirett |
| Solution 3 | Marcus |
| Solution 4 | mrmicrowaveoven |
| Solution 5 | paulz |

