Skip to content
Discussion options

You must be logged in to vote

For React Native I would not use @thesvg/react directly, since that package is for web React components.

The base thesvg package gives you raw SVG strings, so in React Native you can render them with react-native-svg:

import { SvgXml } from 'react-native-svg';
import github from 'thesvg/github';

export function GithubIcon() {
  return <SvgXml xml={github.svg} width={24} height={24} />;
}

Install both packages:

npm install thesvg react-native-svg

If by dynamic import you mean choosing an icon by name at runtime, Metro still needs to know possible imports at build time. A small map is usually the safest option:

const icons = {
  github: () => import('thesvg/github'),
  figma: () => import('…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by quddus-larik
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants