简体   繁体   中英

How do I import an image into my React Native app?

I'm new to React Native and I'm trying to include an image in my app via:

function Interactions(props) {
    return (
        <View>
            <Image source={require('./assets/comment_32.png')} />
            <Text>{props.info.replies}</Text>
        </View>
    );
}

But I'm getting the following error - TypeError: Failed to construct 'Image': Please use the 'new' operator, this DOM object constructor cannot be called as a function.

You need to import the Image component from react-native.

import { Image } from 'react-native';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM