Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Application keeps crashing when using svg with xlinkHref #1099

Closed
tiagocorreiaitcenter opened this issue Sep 11, 2019 · 3 comments
Closed

Application keeps crashing when using svg with xlinkHref #1099

tiagocorreiaitcenter opened this issue Sep 11, 2019 · 3 comments
Labels

Comments

@tiagocorreiaitcenter
Copy link

tiagocorreiaitcenter commented Sep 11, 2019

Everytime I try to import the following svg into the application it crashes and im forced to reinstall it, here's my svg code,

import React from 'react';
import Svg, { Defs, LinearGradient, Stop, G, Path } from 'react-native-svg'

const SvgComponent = (props) => (
  <Svg viewBox="0 0 340.24 340.22" {...props}>
    <Defs>
      <LinearGradient
        id="prefix__a"
        x1={-2188.73}
        y1={3359.76}
        x2={-1447.38}
        y2={3359.76}
        gradientTransform="rotate(45 2934.26 4030.054)"
        gradientUnits="userSpaceOnUse">
        <Stop offset={0} stopColor="#fff" stopOpacity={0} />
        <Stop offset={1} stopColor="#fff" />
      </LinearGradient>
      <LinearGradient
        id="prefix__b"
        x1={223.69}
        y1={-43.81}
        x2={-0.53}
        y2={180.41}
        xlinkHref="#prefix__a"
      />
      <LinearGradient
        id="prefix__c"
        x1={419.4}
        y1={-69.39}
        x2={139.18}
        y2={210.83}
        xlinkHref="#prefix__a"
      />
    </Defs>
    <G data-name="Layer 2">
      <Path
        d="M175 192.69a42.08 42.08 0 00-29.86 12.36l-99 99a139.82 139.82 0 0099.29 41.1h199.49l-140-140A42.13 42.13 0 00175 192.69z"
        transform="translate(-4.88 -4.89)"
        fill="url(#prefix__a)"
      />
      <Path
        d="M6.89 4.89l138.22 138.23a42.3 42.3 0 0059.79 0l98-98a139.74 139.74 0 00-98.2-40.23z"
        transform="translate(-4.88 -4.89)"
        fill="url(#prefix__b)"
      />
      <Path
        d="M175 155.48a42.08 42.08 0 01-29.86-12.36L6.89 4.89h-2v199.82A139.8 139.8 0 0046 303.91l.11.1 99-99a42.3 42.3 0 0159.79 0l140 140h.2V145.43A140 140 0 00303.91 46c-.32-.32-.69-.6-1-.93l-98 98A42.13 42.13 0 01175 155.48z"
        transform="translate(-4.88 -4.89)"
        fill="url(#prefix__c)"
      />
    </G>
  </Svg>
);

export default SvgComponent;

I think the issue is related to xlinkHref, beucase all the over svg's have worked so far but none had xlinkHref.

metro.config.js

`const { getDefaultConfig } = require('metro-config');

module.exports = (async () => {
  const {
    resolver: { sourceExts, assetExts },
  } = await getDefaultConfig();
  return {
    transformer: {
      babelTransformerPath: require.resolve('react-native-svg-transformer'),
    },
    resolver: {
      assetExts: assetExts.filter((ext) => ext !== 'svg'),
      sourceExts: [...sourceExts, 'svg'],
    },
  };
})();

Versions:

    "react": "16.8.6",
    "react-native": "0.60.5",
    "react-native-svg": "^9.9.3",
    "react-native-svg-transformer": "^0.13.0",
@tiagocorreiaitcenter
Copy link
Author

Kinda need some feedback on this one

@msand
Copy link
Collaborator

msand commented Sep 27, 2019

Can you try with 18828c0

@msand msand added the bug label Sep 27, 2019
@msand msand closed this as completed in 18828c0 Sep 28, 2019
msand pushed a commit that referenced this issue Sep 28, 2019
## [9.9.7](v9.9.6...v9.9.7) (2019-09-28)

### Bug Fixes

* add gradientTransform to d.ts ([3f08c46](3f08c46)), closes [#1069](#1069)
* handling of gradients without stops ([18828c0](18828c0)), closes [#1099](#1099)
* handling of rounded rect ([c12d66e](c12d66e)), closes [#1112](#1112)
* units in linear and radial gradients ([70c54e6](70c54e6)), closes [#1110](#1110) [#1118](#1118)
@msand
Copy link
Collaborator

msand commented Sep 28, 2019

🎉 This issue has been resolved in version 9.9.7 🎉

The release is available on:

Your semantic-release bot 📦🚀

@msand msand added the released label Sep 28, 2019
JackWillie added a commit to JackWillie/react-native-svg that referenced this issue Nov 27, 2022
## [9.9.7](software-mansion/react-native-svg@v9.9.6...v9.9.7) (2019-09-28)

### Bug Fixes

* add gradientTransform to d.ts ([3f08c46](software-mansion/react-native-svg@3f08c46)), closes [#1069](software-mansion/react-native-svg#1069)
* handling of gradients without stops ([18828c0](software-mansion/react-native-svg@18828c0)), closes [#1099](software-mansion/react-native-svg#1099)
* handling of rounded rect ([c12d66e](software-mansion/react-native-svg@c12d66e)), closes [#1112](software-mansion/react-native-svg#1112)
* units in linear and radial gradients ([70c54e6](software-mansion/react-native-svg@70c54e6)), closes [#1110](software-mansion/react-native-svg#1110) [#1118](software-mansion/react-native-svg#1118)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants