So, I have an app that randomly selects pokemon from a list to build a team of pokemon for the user.
I know how to import images to use in a react app. But how would I serve an image to a user using react? I have the sprites located in two separate places currently because I was trying to see if I needed to send from the client or server side. But my file structure is as follows
client/
src/
components/
sprites/
pokemon.js
server.js
sprites/
When the page loads, it requests a random pokemon from the server. Then this code executes
<h2>Pokemon</h2>
<ul>
{this.state.pokemon.map(pokemon =>
<li key={pokemon.id}> <img src={'./sprites/' + pokemon.name + '.png'} alt={pokemon.name}></img> {pokemon.name} {pokemon.galar_dex} </li>
)}
</ul>
<br/>
But instead of showing an image, I am shown the alt text. How would I serve an image to the user this way?