i have this array of objects i am looping through to display its data, however when i am using the img tag in the loop, images won't show
i have tried using react-image, doesn't render obviously. i realized that if the src is a path instead of a link, image doesn't show, it only shows if the src was a link
// App.js
import React, {Component} from 'react';
import './App.css';
import { projects } from './myData';
import Img from "react-image";
class App extends Component {
render(){
return (
<div className="App">
{projects.map(p => {
return <img key={p.id} src={p.src} alt="can't show image" />;
})}
</div>
);
}
}
export default App;
// myData.js
export const projects = [
{
id: 1,
name: "Tic Tac Toe game",
src: "http://www.m9c.net/uploads/15682238971.gif"
},
{
id: 2,
name: "Tic Tac Toe game",
src: "./images/tictactoe.gif"
}
];
i wanna be able to use local path to show the images, my whole project doesn't communicate with a server an i don't need it to.
file:///? Are you building using webpack? create-react-app? Did you put the images in the public folder?