Append HTML string to Next.js header
P粉031492081
P粉031492081 2023-08-29 16:05:28
0
1
513
<p>I am getting data from API and it gives me an object with attribute <code>head: '<title>dummy title<title>'</code></p> <p>When I call the HTML string in the head tag, it doesn't display anything. My code: </p> <pre class="brush:php;toolbar:false;"><Head>{data.head}</Head></pre> <p>I also tried: </p> <pre class="brush:php;toolbar:false;"><Head> <div dangerouslySetInnerHTML={{ __html: data.head }}></div> </Head></pre> <p>code<code><div dangerouslySetInnerHTML={{ __html: data.head }}></div></code> works for me in body but not in head, Because div cannot be called in the head. I also tried using Fragment instead of div but it doesn't work even in body. </p>
P粉031492081
P粉031492081

reply all(1)
P粉032900484

You cannot directly convert a string or object into a label. For your use case you can split the header object to get a specific header and use that.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template