
Security News
Open Source Maintainers Feeling the Weight of the EU’s Cyber Resilience Act
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
expo-svg-uri
Advanced tools
SvgUri
is a React Native component that allows rendering SVG images from either a URI source or raw XML data. It uses react-native-svg
for rendering and supports additional props for customization. Now, this component works for both React Native Bare and Expo client applications.
react-native-svg
npm install --save expo-svg-uri
OR
yarn add expo-svg-uri
OR
pnpm add expo-svg-uri
import SvgUri from "expo-svg-uri";
export default function Example() {
return (
<>
{/* Load SVG from URL */}
<SvgUri
width={200}
height={200}
source={{
uri: "https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/heart.svg",
}}
/>
{/* Load SVG from local file */}
<SvgUri
width={200}
height={200}
source={require("@/assets/images/heart.svg")}
/>
{/* Load SVG from XML string */}
<SvgUri
width={200}
height={200}
xml='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
<path d="M50,30c9-22 42-24 48,0c5,40-40,40-48,65c-8-25-54-25-48-65c 6-24 39-22 48,0 z" fill="#F00" stroke="#000"/>
</svg>
'
/>
</>
);
}
Prop | Type | Description |
---|---|---|
source | ImageSourcePropType | null | Remote or local source of the SVG file |
xml | string | null | Raw SVG XML string |
loading | React.JSX.Element | Custom loading indicator while fetching |
fallback | React.JSX.Element | Component displayed if SVG fails to load |
onError | (error: Error) => void | Callback when an error occurs |
...props | SvgProps & AdditionalProps | Any additional props for react-native-svg elements |
If an invalid SVG is provided, the onError
prop will be triggered:
<SvgUri
source={{ uri: "https://example.com/invalid.svg" }}
onError={(error) => console.error("SVG Error:", error)}
fallback={<Text>Error loading SVG</Text>}
loading={<Text>Loading...</Text>}
/>
react-native-svg
to be installed.This component is open-source and available under the MIT license.
SvgUri
is developed by Thong Dang. You can contact me at thongdn.it@gmail.com.
If you like my project, you can support me or star (like) for it.
[2.0.0] - 17/03/2025
FAQs
Render an SVG Image
The npm package expo-svg-uri receives a total of 307 weekly downloads. As such, expo-svg-uri popularity was classified as not popular.
We found that expo-svg-uri demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.