Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

How to embed text in SVGR component in React Native

$
0
0

I have an icon that contains company logo and next to this logo should be displayed counter, I have created a component on https://react-svgr.com/ and I tried to use Text Svg element like so

import Svg, { Path, Text} from "react-native-svg";import type { IconProps } from "./iconpropsType";<Svg width={54} height={36} fill="none" {...props}><Path      d="company logo"      fill={props.iconColor}    /><Text fill={props.iconColor}>7</Text></Svg>

but I'm getting and error that says

Type '{ children: string; fill: Color; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<TextProps, any, any>> & Readonly<TextProps>'.  Property 'children' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<TextProps, any, any>> & Readonly<TextProps>'.ts(2322)

according to MDN this should be a valid use of SVG text element https://developer.mozilla.org/en-US/docs/Web/SVG/Element/text and indeed the text gets rendered, but there is no children prop in TextProps.What is the proper usage of Text element in React SVGR? The docs do net get into details of elements too much

Thanks


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>