Answer the question
In order to leave comments, you need to log in
How to specify relative path for links in React?
There is such a code in it, the ejs template engine was used, I am now rewriting it to react, so how can I specify this path in the a tag?
<ul>
{posts.length &&
posts.forEach(({ id, title, createdAt, text, author }) => {
<li>
<article>
<h2>
<a href="/posts/<%= id %>">{title}</a>
</h2>
<p>{text}</p>
<div class="info">
<span>{createdAt.toLocaleDateString()}</span>
<span>{author}</span>
</div>
<button class="btn-delete" data-id={id} onClick={deletePost}>
<i class="fas fa-trash-alt" data-id={id}></i>
</button>
</article>
</li>;
})}
</ul>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question