Devla
Devla

Reputation: 356

Next.js cant use dynamic image url

I am trying to assign image src which i get from api :

        {articles.items.map((item, key) => (
            <div class="col-lg-4">
                <div class="blog-card">
                <img src="{item.thumbnail}"/> // here
                <h2>{item.title}</h2>
          
        <p dangerouslySetInnerHTML={{__html: ' ' + item.description.slice(0,450) + '...'}}></p>
        <div>
        {item.categories.map((tag, key) => (
        <span className="tag">{tag}</span>
              ))}

But instead i am getting this in my html :

<img src="{item.thumbnail}"/> // Not really converted

How to load my dynamic image ?

Upvotes: 0

Views: 305

Answers (1)

Lyuboslav Alexandrov
Lyuboslav Alexandrov

Reputation: 367

Just remove the parentheses:

<img src={item.thumbnail} />

Upvotes: 3

Related Questions