File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -45,6 +45,8 @@ exports[`cli --native 1`] = `
4545"import React from \\ "react\\ ";
4646import Svg, { Path } from \\ "react-native-svg\\ ";
4747
48+ // SVGR has dropped some elements not supported by react-native-svg: title
49+
4850const One = props => (
4951 <Svg width = { 48 } height = { 1 } viewBox =\\"0 0 48 1\\" { ... props } >
5052 <Path d =\\"M0 0h48v1H0z\\" fill =\\"#063855\\" fillRule =\\"evenodd\\" />
Original file line number Diff line number Diff line change @@ -30,15 +30,16 @@ const toReactNative = () => ({
3030 const component = elementToComponent [ path . node . name ]
3131 if ( component ) {
3232 path . node . name = component
33- state . reactNativeSvgReplacedComponents = state . reactNativeSvgReplacedComponents || new Set ( )
33+ state . reactNativeSvgReplacedComponents =
34+ state . reactNativeSvgReplacedComponents || new Set ( )
3435 state . reactNativeSvgReplacedComponents . add ( component )
3536 return
3637 }
3738
3839 // Remove element if not supported
3940 if ( ! componentToElement [ path . node . name ] ) {
4041 state . unsupportedComponents = state . unsupportedComponents || new Set ( )
41- state . unsupportedComponents . add ( component )
42+ state . unsupportedComponents . add ( path . node . name )
4243 path . remove ( )
4344 }
4445 } ,
Original file line number Diff line number Diff line change 1- const componentsToImport = components =>
1+ const componentsToList = components =>
22 [ ...components ] . filter ( component => component !== 'Svg' ) . join ( ', ' )
33
4+ const logUnsupportedComponents = components => {
5+ if ( ! components . size ) return ''
6+ return `
7+ // SVGR has dropped some elements not supported by react-native-svg: ${ componentsToList (
8+ components ,
9+ ) }
10+ `
11+ }
12+
413export default ( opts = { } ) => ( code , state ) => {
5- const { reactNativeSvgReplacedComponents = new Set ( ) } = state
14+ const {
15+ reactNativeSvgReplacedComponents = new Set ( ) ,
16+ unsupportedComponents = new Set ( ) ,
17+ } = state
618
719 return `import React from 'react'
8- import Svg, { ${ componentsToImport (
20+ import Svg, { ${ componentsToList (
921 reactNativeSvgReplacedComponents ,
1022 ) } } from 'react-native-svg';
23+ ${ logUnsupportedComponents ( unsupportedComponents ) }
24+
1125
1226 const ${ state . componentName } = (${ opts . expandProps ? 'props' : '' } ) => ${ code }
1327
You can’t perform that action at this time.
0 commit comments