target / react-native-svg-parser

Parses SVG files and converts to 'react-native-svg' format objects. NOTE: This project has been archived.
MIT License
42 stars 16 forks source link

CSS not applied #10

Closed guizmo closed 6 years ago

guizmo commented 6 years ago

Hi there

I am passing my CSS string in the second parameter but it does not seem to work

{ ReactNativeSvgParser(fileString, `path: { fill: #444; }`, {width: 80, height: 80}) }

Am i doing it wrong ?

richaagrawal12 commented 6 years ago

@guizmo can you please share your code, how you implement it. I am facing this error "Unable to resolve "react-native-svg-parser" from "src\Router.js".

a-r-d commented 6 years ago

@guizmo yes you need to pass it as a string. e.g. -

import ReactNativeSvgParser from 'react-native-svg-parser'

const svgString = `<svg height="100" width="100">
  <circle cx="50" cy="50" r="40" class="red-circle" />
</svg> 
`
const cssString = `
.red-circle {
  fill: red;
  stroke: black;
  stroke-width: 3;
}
`

const svgNode = ReactNativeSvgParser(svgString, cssString)
a-r-d commented 6 years ago

closing this, please see example, and I will add this more explicit example to the readme