A simple example app that shows how you can use SVG files in React Native.
The SVG images used in this app can be found from the logos folder.
The .svg
files can be imported inside a React component:
import Logo from './logo.svg';
The images can then be used as a component:
<Logo width={120} height={40} />
Make sure that you have react-native-cli
installed (npm install -g react-native-cli
) and XCode (for iOS development) / Android Studio (for Android development) installed and working.
- Go to "Building Projects with Native Code" tab and follow the guide: https://facebook.github.io/react-native/docs/getting-started.html
git clone git@github.com:kristerkari/react-native-svg-example.git
cd react-native-svg-example
npm install
You can open a new terminal tab to run React Native's packager.
npm start
First make sure that your Android emulator or iOS simulator is working, then:
npm run ios
or
npm run android
or
npm run web
iOS - Android - Web