You are probably working on a mobile and you want to design images that you got from an API or maybe the path to that image is stored using React Context API, but there is one problem: whenever you do this

const my_variable = '../assets/image.jpg';<Imagesource={require(my_variable)}/>

You get an error.

The solution to this problem is to require the file in the variable like this

const my_variable = require('../assets/image.jpg');<Imagesource={my_variable}/>

Doing this will definitely solve your problem and If you have any question regarding React Native or this specific post, feel free to ask, who knows, maybe other developers are going through the same problem and discussing certain issues here might help a lot of people.


If you are currently working on an app with React Native and you are using Laravel as your backend, you have probably encountered this problem.

And this article will help you solve this problem with just ONE SIMPLE TRICK.

SOMETIMES THIS PROBLEM IS CAUSED BY HOW YOU START YOUR LARAVEL APP

We all know how to start a Laravel server with the…


If you are young, you just finished high school and you’re looking for a future career, you’re at the right place, but if you’re old, unhappy with your current career or you’re just passionate about software development, you’re at the right place!

Photo by Safar Safarov on Unsplash

As a kid I didn’t really know what…

Kevin Ilondo

Self taught programmer, PHP Web developer, lover of technology and programming.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store