react-native-svg: React-native-uri no longer well supported - Can react-native-svg support SvgXmlData instead?
Feature Request
React-native-uri no longer seems supported (last commit was in 2018 and many open PRs) - read more
Can react-native-community pull in this use case or otherwise take over and support this library?
Why it is needed
React-native-svg-uri is unique because it allows rendering SVGs from a data string. This is crucial for anyone composing their svgs on the server. (svgXmlData)
react-native-svg-uri currently also supports rendering a static image. IMO, react-native-uri doesn’t actually need to support fetching from a static file since react-native-svg-transformer fills that niche.
Solutions
One idea is to clone react-native-svg-uri into react-native-community/react-native-svg-uri, merge in the current existing pull requests and do minor bug fixes support the last few RN versions.
Another idea is to create a new SVG data rendering component from scratch inside react-native-svg
import {SvgXmlData} from 'react-native-svg'; ... <SvgXmlData source={'svg'} />
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 4
- Comments: 16
Commits related to this issue
- feature: Implement SvgUri and SvgXml #1074 — committed to software-mansion/react-native-svg by msand 5 years ago
With uri support:
Amazing work and quick response - thank you so much!
I was able to run the example in the readme no problem. However, I found a few cases blocking me from using my existing web svgs:
Failure 1: Adding inline style to text
TypeError: Cannot read property 'trim' of undefinedFailure 2: Including a <style> tag
Failure 3: Accessibility elements title + desc
It also broke on
<use xlink:href ... />but that’s not supported in svg2, and href works fine.Thanks again!
@etaiklein I’ve optimized the implementation a bit, and added hooks based ones as well.
Perhaps something like this SvgFromXml.js:
Example App.js:
After your changes, I was able to get my server-side generated code working (without SVGO) with the following changes to my svg code:
<title>and<desc>xlink:hrefwithhref<style>and replace font-family attribute font with registered fonts