Questions tagged [dangerouslysetinnerhtml]
64 questions
11
votes
4 answers
Javascript dynamically inserted later on: how to make it run?
I have scripts In my React app that are inserted dynamically later on. The scripts don't load.
In my database there is a field called content, which contains data that includes html and javascript. There are many records and each record can include…

Nick
- 3,496
- 7
- 42
- 96
8
votes
1 answer
Next.JS - Gist's embedded in markdown rendered via dangerouslySetInnerHTML only show after full page load, not React route load
I have a series of blog posts stored in MD files, some of these contain multiple Gist embeds in the form of script tags.
The MD contents are rendered to the page via dangerouslySetInnerHTML, and all is fine when the page is navigated to directly.…

Rob Earlam
- 864
- 1
- 8
- 15
4
votes
0 answers
How can I Parse a string containing JSX into JSX components
I am currently trying to parse a string that contains JSX into literal JSX,and inject it into the return of my component:
import react from "react";
import { makeStyles } from '@material-ui/core/styles';
const useStyles = makeStyles(theme => ({
…

0xdeadbeef
- 101
- 1
- 5
3
votes
2 answers
How to set attribute "dangerouslySetInnerHTML" with ellipsis using antd?
I need to show comment with ellipsis. I have used antd's Paragraph Typography for it.
My problem is that comment can also contain html attributes (link to tagged users) so I also need to set dangerouslySetInnerHTML in the component. How to set this…

Nikita Jain
- 53
- 7
2
votes
0 answers
How to get HTML file from firebase storage bucket and display it on React Page
I have tried a few things such as dangerouslySetInnerHTML and nothing has worked. This is my latest attempt...
this.state={article:"firebaseStorageLinkToHTML"}
createMarkup(){ return {__html: this.state.article}; };
return(

Matt102065
- 75
- 6
2
votes
1 answer
Why does NextJS give this hydration error on dev server build but not production build?
If you use create-next-app and paste this code, you get a hydration error on the client when running the next dev server.
pages/index.js
export async function getServerSideProps(context) {
const x = Math.random();
const script = `