Warning: React.jsx: type is invalid -- expected a string when adding an image as a component - Stack Overflow

Trying to create a body structure on my React Native app using images as buttons.I get hit with an err

Trying to create a body structure on my React Native app using images as buttons.

I get hit with an error "Warning: React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: number." at this particular segment.

PointsHistory.tsx:

import Buttonicon from "../assets/buttonicon.svg";

<Buttonicon
  style={[styles.buttonicon, styles.icon25Layout]}
  width={24}
  height={24}
>

What am I doing wrong here?

Trying to create a body structure on my React Native app using images as buttons.

I get hit with an error "Warning: React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: number." at this particular segment.

PointsHistory.tsx:

import Buttonicon from "../assets/buttonicon.svg";

<Buttonicon
  style={[styles.buttonicon, styles.icon25Layout]}
  width={24}
  height={24}
>

What am I doing wrong here?

Share Improve this question asked Mar 6 at 7:31 Udhayan NairUdhayan Nair 4702 gold badges8 silver badges25 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

You can use image component for svg image display , but it will only work for iOS .

    import { Image } from 'react-native';

  const App = () => {
  return (
    <Image source={require('./assets/image.svg')} style={{ width: 100, height: 100 }} />
  );
};

If you want to support both platform react-native-svg is the best choice

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744991882a4604956.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信