I am using ImageBackground from react-native lib. ImageBackground using source={require('asd.png')} for example.
But I am trying to add variable inside to require.
const [image,setImage] = useState('./asd.png')
.then(image => {
setImage(image.path) // gives 'something.png'
});
<ImageBackground source={require(image)></ImageBackground>
But I am getting error. Invalid call at line 122: require(image)
This is the proper way to use
ImageBackground
Check this Snack to see working example
Also, have a look at the docs for more help.
As the Docs says,