androidreact-nativereact-native-svg

react native svg error child.isClassAccessorProperty is not a function on upgrading react native from 68.1 to 70.6


Thanks in advance

I received the below error when I tried to upgrade react native from 68.1 to 70.6. I tried this in android.

I ran react-native run-android and everything went well. Upon running the app the metro bundler started loading 99% and showed this error in red screen

error: node_modules/react-native-svg/src/elements/Shape.tsx: /Users/jarenk/Documents/myApp/node_modules/react-native-svg/src/elements/Shape.tsx: child.isClassAccessorProperty is not a function

Can anybody help me on this.

Am using react native SVG and its version was old. I updated it to latest version too. (13.6.0) but still its getting same error.

Error In Detail (If I take Build)

./gradlew assembleRelease

I get following error

error node_modules/react-native-svg/src/elements/Shape.tsx: /Users/jarenk/Documents/myApp/node_modules/react-native-svg/src/elements/Shape.tsx: child.isClassAccessorProperty is not a function.
TypeError: /Users/jarenk/Documents/myApp/node_modules/react-native-svg/src/elements/Shape.tsx: child.isClassAccessorProperty is not a function
    at /Users/jarenk/Documents/myApp/node_modules/@babel/plugin-transform-typescript/lib/index.js:361:89
    at Array.forEach (<anonymous>)
    at PluginPass.Class (/Users/jarenk/Documents/myApp/node_modules/@babel/plugin-transform-typescript/lib/index.js:353:31)
    at newFn (/Users/jarenk/Documents/myApp/node_modules/@babel/traverse/lib/visitors.js:171:21)
    at NodePath._call (/Users/jarenk/Documents/myApp/node_modules/@babel/traverse/lib/path/context.js:53:20)
    at NodePath.call (/Users/jarenk/Documents/myApp/node_modules/@babel/traverse/lib/path/context.js:40:17)
    at NodePath.visit (/Users/jarenk/Documents/myApp/node_modules/@babel/traverse/lib/path/context.js:90:31)
    at TraversalContext.visitQueue (/Users/jarenk/Documents/myApp/node_modules/@babel/traverse/lib/context.js:110:16)
    at TraversalContext.visitQueue (/Users/jarenk/Documents/myApp/node_modules/@babel/traverse/lib/context.js:116:21)
info Run CLI with --verbose flag for more details.

Once again thank you.


Solution

  • Updating the package.json file helped me to resolve this.

    just downgrade the babel versions like below

    Also make sure same below version are in package-lock.json file

    "@babel/core": "7.12.9",
    "@babel/runtime": "7.12.5"