godaddy / svgs

svgs is a compatiblity layer between svg and react-native-svg
MIT License
191 stars 31 forks source link

Text x,y properties cause warnings in React #10

Closed schlaup closed 7 years ago

schlaup commented 7 years ago

Using React 16 (maybe with React 15 as well - I did not try) I get the following warning in the debug console:

Warning: Failed prop type: Invalid prop 'x' of type 'number' supplied to 'Text', expected 'string'.

In the code I can see that you declare the properties' types correctly:

Text.propTypes = {
  x: PropTypes.string,

but you pass the values as is without converting them to strings:

  return <text { ...prepare(rest) } { ...{ x, y, dx, dy, rotate } } />;

Shouldn't this be something like:

  return <text { ...prepare(rest) } { ...{ x !== undefined ? x.toString() : x, [etc.] } } />;

Thanks for the module! Nice work!

3rd-Eden commented 7 years ago

Fixed in 3.0.1 -- Thanks for taking the time to report this issue.