How to fix the “Invalid prop ‘source’ supplied to Image” error with React-Native Image?

To fix the “Invalid prop ‘source’ supplied to Image” error with React-Native Image, we set the source prop of the Image component to the value returned by calling require with the image path.

For instance, we add the Image by writing

<Image source={require("./my-icon.png")} />;

We set the source to the value returned by require to add the image at my-icon.png.