In my NFTDetails component is a description that comes out of a JSON. There are nn in it. There is no new line when I use the value of the JSON in a div, but there are new lines in the Firefox console when I console.log() it.
How can I use the n to display new Lines in my div.
NFTDetails.jsx – Snippet
JavaScript
x
19
19
1
const NFTDetails = ({nfts}) => {
2
const { id } = useParams();
3
const navigate = useNavigate()
4
5
const metadata = useMemo(
6
() => nfts.find((nft) => String(nft.id) === id),
7
[nfts, id]
8
);
9
10
return (
11
<div className="NFTDetails">
12
<div className="TextCard">
13
<div className="NFTCName">{metadata.name}</div>
14
<div className="Description">
15
<p className='DescriptionText'>Description:</p>
16
<p>{metadata.description}</p>
17
</div>
18
</div>
19
metadata.description(JSON)
JavaScript
1
4
1
{
2
"description":"🧬 CLONE X 🧬nn20,000 next-gen Avatars, by RTFKT and Takashi Murakami 🌸nnIf you own a clone with even one Murakami trait please read the terms regarding third-party content here: https://rtfkt.com/legal-2B.nnYou are not entitled to a commercial license if you own an avatar with any traits created by Murakami."
3
}
4
Advertisement
Answer
use white-space: pre-line;
to leave whitespaces as in description
https://developer.mozilla.org/en-US/docs/Web/CSS/white-space