kristerkari / react-native-svg-transformer

Import SVG files in your React Native project the same way that you would in a Web application.
MIT License
1.58k stars 115 forks source link

svg does not display properly when used with styled-components #303

Closed valn1 closed 12 months ago

valn1 commented 12 months ago

when using the styled-components library to display an svg, it does not display properly

import styled from "styled-components/native";

import Inmap from "../../assets/logos/inmap.svg";
import { Screen } from "../../components/Screen";

const Suffix = styled(Inmap)``;

const Register = () => {
    return (
        <Screen>
            <Suffix />
            <Inmap />
        </Screen>
    );
};

export default Register;

original svg inmap rendered svg image

valn1 commented 12 months ago

it seems the library causes it to loose this information from the file style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd"

valn1 commented 12 months ago
const Suffix = styled(Inmap)`
    shape-rendering: geometricPrecision;
    text-rendering: geometricPrecision;
    image-rendering: optimizeQuality;
    fill-rule: evenodd;
    clip-rule: evenodd;
`;

nevermind, adding the styles to the component fixes the issue