I've created function which returns me drawed photo. I'm trying to assign it as an img url, but instead of html element it returns me an object. How can I refer to an html element instead of to object?
This is function that returns me an image:
function workoutImage() {
const images = [
{
img1: "./images/workout-image1.jpg",
},
{
img2: "./images/workout-image2.jpg",
},
{
img3: "./images/workout-image3.jpg",
},
];
const imageIndex = Math.floor(Math.random() * images.length);
let returnImage = images[imageIndex];
return returnImage;
}
export default workoutImage;
and here's component where I'm trying to display it:
function WorkoutsDiary() {
let workoutImage = workoutImageDraw();
return (
<Container>
<Content>
{showWorkouts &&
showWorkouts.map((workout, key) => (
<Image key={key}>
<Link to={`/exercise/` + workout.id}>
<img src={workoutImage} alt="" />
</Link>
</Image>
))}
</Content>
</Container>
);
}
when I do a console log, it looks like this:
