felipecespedes / react-native-bigheads

Big Heads avatars for React Native
MIT License
93 stars 13 forks source link

Add types for SVG Props + SVG Ref #6

Closed mrousavy closed 4 years ago

mrousavy commented 4 years ago

For anyone wondering how to convert this to a PNG, use the svgRef= property to attach a ref created by React.useRef(), then call toDataURL on that ref instance (ref.current object)

felipecespedes commented 4 years ago

@mrousavy Thanks for opening this PR. I really like the idea of including the svgRef prop, however I didn't get why extending BaseProps & AvatarProps from SvgProps would be beneficial. I see BaseProps & AvatarProps as a high-level data models, so if you want to get the raw SVG just use the svgRef prop

mrousavy commented 4 years ago

@felipecespedes Well, in Base you use every prop to assign it do some part, and the container/style props get assigned to the View. Then, for every other prop, you use {...rest} at the <Svg, which doesn't make sense, since there are no properties left. If you hover over that rest var using VSCode, you can see that the type of that is empty. So I've extended from SvgProps to let the user also manually specify width, height, x, y (viewport), and whatever other properties there might be. There are no new required props anyways, just more options

felipecespedes commented 4 years ago

@mrousavy I see your point and makes sense, thanks for clarifying.

mrousavy commented 4 years ago

Thanks for merging. Could you create a release once you have some time? I'm not really comfortable with using patches for that lol

felipecespedes commented 4 years ago

the new version 1.1.0 is now live :rocket: