我正在尝试将来自请求的HTML呈现为字符串。我尝试过将其作为道具传递,并直接在JSX中渲染该道具。没事。我不确定是否需要使用renderProps或dragonallySetInnerHTML。但是我真的不想直接引用DOM
import React, { Component } from 'react'
class SomePageComponent extends Component {
state = {
stateData: ''
}
componentDidMount = async() => {
const { request } = this.props
await request().then(data => this.setState({
stateData: data
})
)
}
render() {
const { stateData } = this.state
return (
<div>
//so i need to put it somwhere here and i tried like tis below
<div>{stateData}</div>
//aslo i've tried like this
<stateData />
</div>
)
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
`