diff --git a/TestsExample/App.js b/TestsExample/App.js index c5961c17..17bdd126 100644 --- a/TestsExample/App.js +++ b/TestsExample/App.js @@ -12,6 +12,7 @@ import Test2071 from './src/Test2071'; import Test2089 from './src/Test2089'; import Test2196 from './src/Test2196'; import Test2266 from './src/Test2266'; +import Test1986 from './src/Test1986'; export default function App() { return ; diff --git a/TestsExample/src/Test1986.tsx b/TestsExample/src/Test1986.tsx new file mode 100644 index 00000000..b6845881 --- /dev/null +++ b/TestsExample/src/Test1986.tsx @@ -0,0 +1,29 @@ +import React, {useRef, useState} from 'react'; +import {Button, Image, View} from 'react-native'; +import {Circle, Svg} from 'react-native-svg'; + +export default () => { + const ref = useRef(null); + const [s, setS] = useState(''); + return ( + + + ); +}; diff --git a/android/src/main/java/com/horcrux/svg/SvgView.java b/android/src/main/java/com/horcrux/svg/SvgView.java index bfbbe332..dd50add2 100644 --- a/android/src/main/java/com/horcrux/svg/SvgView.java +++ b/android/src/main/java/com/horcrux/svg/SvgView.java @@ -339,7 +339,7 @@ public class SvgView extends ReactViewGroup implements ReactCompoundView, ReactC bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream); bitmap.recycle(); byte[] bitmapBytes = stream.toByteArray(); - return Base64.encodeToString(bitmapBytes, Base64.DEFAULT); + return Base64.encodeToString(bitmapBytes, Base64.NO_WRAP); } String toDataURL(int width, int height) { @@ -353,7 +353,7 @@ public class SvgView extends ReactViewGroup implements ReactCompoundView, ReactC bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream); bitmap.recycle(); byte[] bitmapBytes = stream.toByteArray(); - return Base64.encodeToString(bitmapBytes, Base64.DEFAULT); + return Base64.encodeToString(bitmapBytes, Base64.NO_WRAP); } void enableTouchEvents() { diff --git a/apple/Elements/RNSVGSvgView.mm b/apple/Elements/RNSVGSvgView.mm index 3047b4b8..7addf84e 100644 --- a/apple/Elements/RNSVGSvgView.mm +++ b/apple/Elements/RNSVGSvgView.mm @@ -344,10 +344,10 @@ using namespace facebook::react; #endif #if !TARGET_OS_OSX // [macOS] NSData *imageData = UIImagePNGRepresentation(image); - NSString *base64 = [imageData base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength]; + NSString *base64 = [imageData base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithLineFeed]; #else // [macOS NSData *imageData = UIImagePNGRepresentation(UIGraphicsGetImageFromCurrentImageContext()); - NSString *base64 = [imageData base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength]; + NSString *base64 = [imageData base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithLineFeed]; UIGraphicsEndImageContext(); #endif // macOS] return base64;