react-art icon indicating copy to clipboard operation
react-art copied to clipboard

correct way of importing *.svg files

Open DeDuckProject opened this issue 9 years ago • 0 comments

Hi, I'm using react-art to display SVGs in the following way, I open the svg file in a text editor and copy its "path" string to a constant in my react-native app.

my icon component render function looks like this:

<Surface width={this.props.size}
                         height={this.props.size}
                         style={{backgroundColor: 'rgba(0,0,0,0)'}}>
                    <Group x={this.props.x} y={this.props.y}>
                        <Shape d={this.props.path} fill={this.props.fillColor}/>
                    </Group>
                </Surface>

where this.props.path is the path of the svg.

However, in order to share code with my web react app, I would prefer importing the svg as a file (ie. src="/icon.svg" or so) and not take the string from the file and hard-code it.

Is there a proper way of doing this? Or am I looking at this the wrong way?

Cheers, Iftach

DeDuckProject avatar Sep 19 '16 16:09 DeDuckProject