Started Learning React recently (and already posting on stackoverflow :P),
Now this is in my App.js file:
import React from "react";
export default function App(props){
return (
<img src={"./images"+props.img} alt="something" />
)
}
And this is in my index.js file:
import React from "react"
import ReactDOM from "react-dom"
import App from "./App"
ReactDOM.render(<App img="katie-zaferes.png"/>, document.getElementById("root"))
And nothing shows up (actually "something" shows up since it's the alt text), how do I make it work?
I am working in an app created using npx create-react-app
.
Here is how the project looks:
enter image description here
I wanna be able to take the name of the image as argument in the App.js and display it. I know beforehand that the image lies in the image folder
Tried to do a project from Scrimba React course, link to which is below:
https://scrimba.com/learn/learnreact/project-pass-props-to-card-component-co2094669b9fe6bf481f857ae