-
Notifications
You must be signed in to change notification settings - Fork 3
docs: Add React Native to FRAMEWORK-GUIDE #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
docs: Add React Native to FRAMEWORK-GUIDE #4
Conversation
kurdev2020
commented
Nov 11, 2025
- Add React Native framework entry to support table
- Include React Native usage examples
- Document react-native-svg prerequisites
- Add ComponentRef and StyleProp best practices
This commit refactors the CLI command definitions in `cli.js` to use a more concise syntax. Additionally, it updates the framework options to include 'react-native' across various commands, improving the overall usability of the CLI tool.
This commit refactors the CLI command definitions in `cli.ts` for improved readability and consistency. It also enhances error handling across various commands and ensures the inclusion of 'react-native' in framework options, further improving the CLI's functionality.
… SVG component generation This commit adds functionality to the FrameworkTemplateEngine to support the 'react-native' framework. It includes methods for generating React Native components from SVG content, enhancing the overall capability of the framework to handle various front-end technologies.
This commit updates the framework templates to improve TypeScript support for SVG components in React Native. It includes the addition of type imports and extends the component props interface to include `SvgProps`, ensuring better type safety and integration with React Native's styling system.
- Validate ComponentRef usage (not ElementRef) - Enforce StyleProp<ViewStyle> for style prop - Add react-native-svg import checks - Ensure forwardRef wrapper presence
- Generate Arrowbenddownleft and Vite components - Include TypeScript props and forwardRef support - Add index.ts for component exports
- Add React Native usage examples - Include code samples and installation notes
- Update framework count to 9+ - Add React Native usage section - Include code examples and prerequisites - Update CLI framework options list
- Add React Native framework entry to support table - Include React Native usage examples - Document react-native-svg prerequisites - Add ComponentRef and StyleProp best practices
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds React Native framework support to svger-cli, expanding it from 8 to 9 supported frameworks. The implementation generates React Native components using react-native-svg with proper TypeScript types and modern React best practices.
Key Changes
- Added
react-nativeas a supported framework type - Implemented React Native component generation with
react-native-svgintegration - Added proper TypeScript typing using
React.ComponentRef<typeof Svg>andStyleProp<ViewStyle> - Documented React Native usage with examples and prerequisites
Reviewed Changes
Copilot reviewed 11 out of 13 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
yarn.lock |
Added TypeScript 5.9.3 dependency entry (misplaced location) |
src/types/index.ts |
Added react-native to FrameworkType union |
src/core/framework-templates.ts |
Implemented React Native component generator with SVG element conversion |
src/cli.ts |
Updated CLI help text to include react-native option |
frameworks.test.js |
Added React Native test cases and validation logic |
docs/IMPLEMENTATION-SUMMARY.md |
Updated framework count and documentation |
docs/FRAMEWORK-GUIDE.md |
Added comprehensive React Native usage guide |
cli-test-react-native/* |
Added example generated React Native components |
dist/cli.js |
Compiled output of CLI changes |
README.md |
Updated framework count in main documentation |
cli-framework.test.js |
Added react-native to test frameworks array |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| style={style} | ||
| {...props} | ||
| > | ||
| <Defs><LinearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><Stop offset="0%" stop-color="#41D1FF"></Stop><Stop offset="100%" stop-color="#BD34FE"></Stop></LinearGradient><LinearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><Stop offset="0%" stop-color="#FFEA83"></Stop><Stop offset="8.333%" stop-color="#FFDD35"></Stop><Stop offset="100%" stop-color="#FFA800"></Stop></LinearGradient></Defs><Path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></Path><Path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></Path> |
Copilot
AI
Nov 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The SVG attribute conversion is incomplete. The stop-color attribute has not been converted to stopColor in camelCase format. React Native requires all hyphenated SVG attributes to be in camelCase. The convertSVGToReactNative function should include a replacement for stop-color to stopColor.
| <Defs><LinearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><Stop offset="0%" stop-color="#41D1FF"></Stop><Stop offset="100%" stop-color="#BD34FE"></Stop></LinearGradient><LinearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><Stop offset="0%" stop-color="#FFEA83"></Stop><Stop offset="8.333%" stop-color="#FFDD35"></Stop><Stop offset="100%" stop-color="#FFA800"></Stop></LinearGradient></Defs><Path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></Path><Path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></Path> | |
| <Defs><LinearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><Stop offset="0%" stopColor="#41D1FF"></Stop><Stop offset="100%" stopColor="#BD34FE"></Stop></LinearGradient><LinearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><Stop offset="0%" stopColor="#FFEA83"></Stop><Stop offset="8.333%" stopColor="#FFDD35"></Stop><Stop offset="100%" stopColor="#FFA800"></Stop></LinearGradient></Defs><Path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></Path><Path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></Path> |
| .replace(/font-size=/g, 'fontSize=') | ||
| .replace(/font-weight=/g, 'fontWeight=') | ||
| .replace(/text-anchor=/g, 'textAnchor=') | ||
| .replace(/xlink:href=/g, 'href=') |
Copilot
AI
Nov 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The attribute conversion is missing stop-color to stopColor and stop-opacity to stopOpacity conversions. These are commonly used in SVG gradients (as seen in the generated Vite.tsx file). Add .replace(/stop-color=/g, 'stopColor=') and .replace(/stop-opacity=/g, 'stopOpacity=') to the conversion chain.
| .replace(/xlink:href=/g, 'href=') | |
| .replace(/xlink:href=/g, 'href=') | |
| .replace(/stop-color=/g, 'stopColor=') | |
| .replace(/stop-opacity=/g, 'stopOpacity=') |
| const regex = new RegExp(svgTag, 'gi') | ||
| converted = converted.replace(regex, reactNativeTag) |
Copilot
AI
Nov 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating a new RegExp object for each element in the loop is inefficient. The 'gi' flag makes this case-insensitive, which could cause unintended replacements (e.g., matching 'PATH' as well as 'path'). Since SVG tags are case-sensitive in the source and the target React Native components use specific casing, use string replacement with a global flag or compile the regex outside the loop. Consider using .replaceAll() or pre-compiled regexes stored in the elementMap.
| const regex = new RegExp(svgTag, 'gi') | |
| converted = converted.replace(regex, reactNativeTag) | |
| converted = converted.replaceAll(svgTag, reactNativeTag) |
| @@ -0,0 +1,36 @@ | |||
| import React from "react"; | |||
| import Svg, { Defs, Line, LinearGradient, Path, Stop } from "react-native-svg"; | |||
Copilot
AI
Nov 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused import Line.
| import Svg, { Defs, Line, LinearGradient, Path, Stop } from "react-native-svg"; | |
| import Svg from "react-native-svg"; |