score:0

const PokemonCard = (props) => {
    return (    
        <div>
            <h1>{props.name}</h1>
            <img src={props.image} />
            <h1>{props.attack}</h1>
        </div>
    );
}

export default PokemonCard;

score:0

const PokemonCard = (props) => {
    const { image } = props;

    const [img, setImg] = useState(); 

    useEffect(() => {
       import(`../assets/${image}`).then(img => {
           setImg(img.default);
       });
    ), [image]);
    return (    
        <div>
            <h1>{props.name}</h1>
            {img && <img src={img} />}
            <h1>{props.attack}</h1>
        </div>
    );
}

export default PokemonCard;

Related Query

More Query from same tag