'React Native: Unhandled JS Exception: Can't find variable: require

I'm trying to debug my react native project with expo and it recently started giving me this error. For images, I use the require statement as mentioned on the documentation to import. Now it is causing an exception to my whole project. How can I resolve this?

import { Image, StyleSheet, View } from 'react-native'

export default function Logo({ goBack }) {
  return (
    <View style={styles.logo}>
        <Image source={require('../assets/logo.jpg')} style={styles.image} onClick={goBack} />
    </View>
  )
} 


Solution 1:[1]

import { Image, StyleSheet, View } from 'react-native'
import image from '../assets/logo.jpg'
export default function Logo({ goBack }) {
  return (
    <View style={styles.logo}>
        <Image source={image} style={styles.image} onClick={goBack} />
    </View>
  )
} 

try this code

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Vijay