{"id":8106,"date":"2023-06-14T05:32:11","date_gmt":"2023-06-14T05:32:11","guid":{"rendered":"https:\/\/www.bacancytechnology.com\/qanda\/?p=8106"},"modified":"2024-07-18T12:20:52","modified_gmt":"2024-07-18T12:20:52","slug":"svg-file-on-react-native","status":"publish","type":"post","link":"https:\/\/www.bacancytechnology.com\/qanda\/react-native\/svg-file-on-react-native","title":{"rendered":"How to Show an SVG File on React Native?"},"content":{"rendered":"<p>For displaying SVG files in react native projects, you need to install following packages:<br \/>\n<a href=\"https:\/\/www.npmjs.com\/package\/react-native-svg-transformer\" target=\"_blank\" rel=\"noopener\">react-native-svg-transformer<\/a><\/p>\n<p>After installing packages you need to import your SVG files like this:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import React, { useState } from 'react';\r\nimport { View } from 'react-native';\r\nimport WelcomeSVG from \"assets\/icons\/welcome.svg\"\r\n\r\nThe below example shows how to use it:\r\n\r\nreturn (\r\n    &lt;View&gt;\r\n&lt;WelcomeSVG \r\n    width=\"100%\"\r\n    height=\"70%\"\r\n  \t\/&gt;\r\n&lt;\/View&gt;\r\n)\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>The above code will help you in displaying SVG images. You can also set image height and width based on your requirement using width and height properties.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For displaying SVG files in react native projects, you need to install following packages: react-native-svg-transformer After installing packages you need to import your SVG files like this: import React, { useState } from &#8216;react&#8217;; import { View } from &#8216;react-native&#8217;; import WelcomeSVG from &#8220;assets\/icons\/welcome.svg&#8221; The below example shows how to use it: return ( &lt;View&gt; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":8355,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[14],"tags":[],"class_list":["post-8106","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-react-native"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/posts\/8106"}],"collection":[{"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/comments?post=8106"}],"version-history":[{"count":5,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/posts\/8106\/revisions"}],"predecessor-version":[{"id":10946,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/posts\/8106\/revisions\/10946"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/media\/8355"}],"wp:attachment":[{"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/media?parent=8106"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/categories?post=8106"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/tags?post=8106"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}