Abdelrhman Elmahdy
Abdelrhman Elmahdy

Reputation: 1693

Exception thrown while executing UI block when using react-native-svg

My app suddenly started crashing and gave me that error:

Exception thrown while executing UI block: -[__NSCFNumber firstObject]: unrecognized selector 
sent to instance 0xb553069cd18775de`

After sometime I was able isolate the part that generates the error and found out that it has to do with the Svg component imported from react-native-svg.
I tried removing and reinstalling node_modules and I tried reseting the cache, and I even tried creating a new expo app from scratch that does nothing but render an Svg component, but the problem still persists.

And on android I get a different error message:

Error while updating property 'fill' of a View managed by: RNSVGGroup
null
java.Lang.Double cannot be cast to
java.Lang.String

Here's what my code looks like:

import React from 'react';
import { View, StyleSheet } from 'react-native';
import { Svg } from 'react-native-svg';

const App = () =>  (
  <View style={styles.container}>
    <Svg width={100} height={100}>

    </Svg>
  </View>
);

const styles = StyleSheet.create({
  container:{
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  }
});

export default App;

Error Screenshot

Upvotes: 2

Views: 8847

Answers (2)

RC_02
RC_02

Reputation: 3674

I was having same issue when using react-native-heroicons version 3.2.0. https://github.com/ecklf/react-native-heroicons

I downgraded react-native-svg which also gets installed with react-native-heroicons from 13.0.0 to 12.3.0 which then started to work.

To uninstall and install 12.3.0 version of react-native-svg follow below:
npm uninstall react-native-svg
npm install [email protected]

Upvotes: 1

Abdelrhman Elmahdy
Abdelrhman Elmahdy

Reputation: 1693

Based on Javlon's comment the solution is to remove the package using npm uninstall react-native-svg or yarn remove react-native-svg
And then installing it again with expo install react-native-svg

Upvotes: 11

Related Questions