Next.js Discord

Discord Forum

How to replace & in areaLabel?

Answered
Japanese Bobtail posted this in #help-forum
Open in Discord
Avatar
Japanese BobtailOP
I use dangerouslySetInnerHTML to replace & with & (and other characters) inside the link. But how can i replace characters in attributes like aria-label? Do I need to use a custom function to do this?

'<Link href={link} dangerouslySetInnerHTML={{ __html: name }} ariaLabel={Open category ${name}} />
Answered by Japanese Bobtail
Now i'am using the html-entities package to decode all chars for the html attributes: https://www.npmjs.com/package/html-entities
View full answer

1 Reply

Avatar
Japanese BobtailOP
Now i'am using the html-entities package to decode all chars for the html attributes: https://www.npmjs.com/package/html-entities
Answer