I am attempting to load a local image in React js. Following
I have deployed this to Vercel as well as tested locally, so I do not think this is a server issue. I've tried the import method described here as well.
What is wrong here and how can I load a local image?
CodePudding user response:
At the moment I can propose you two options.
- Import your image as a component.
Just place this line of code in the head of your file:
import {ReactComponent as COMPONENT_NAME} from PATH
And place this COMPONENT_NAME in your other components. You can apply stying to it, props and etc. - Import your image path.
import IMAGE_PATH from PATH
And in your component:
<img src={IMAGE_PATH} {...options} />