我怎样才能把它从字符串变成 HTML?

How can i make this from string to HTML?

所以我遇到了这个问题,我的代码被吐到字符串而不是 html 我试图 achieve.My 问题是如何在吐出之前将其转换为 innerHTML?如果我将它推到阵列中,甚至可以这样做吗?我的目标是让它像“待办事项列表应用程序”一样,有多个输入,将每个值吐到每一行。

class Forma extends React.Component {

constructor(){
  super()
  this.state ={
    name: '',
    birth: '',
    age: '',
    items: []
  }
  this.handleInputChange = this.handleInputChange.bind(this)
  this.submitItem = this.submitItem.bind(this)
}

handleInputChange(event){
let name = event.target.name
let birth = event.target.birth
let age = event.target.age
let value = event.target.value

this.setState({ [name] : value, [birth] : value, [age] : value})
}

submitItem (){
  let items = this.state.items
  let item = this.state.name
  let birth =this.state.birth
  let age = this.state.age
  let i = "<th>"
  let z = "</th>"

  let all =i + item + z + i + birth + z + i + age +z
  items.push(all)
 
  
  this.setState({ items: items})
}


  render(){
    return (
      <div className="App">
        <h1>To do List</h1>
        <input type="text" name="name" onChange={this.handleInputChange}></input>
        <input type="text" name="birth" onChange={this.handleInputChange}></input>
        <input type="text" name="age" onChange={this.handleInputChange}></input>
          <button onClick={this.submitItem}>Submit</button>
          

          {this.state.items.map((all) => {
            
            return(
              <tr>{all}<button type="submit" className="delete">Delete</button></tr>

           
            );
          })}
          
      </div>
    );
  }

}

来自文档:dangerouslysetinnerhtml 可用于从字符串

呈现 html

dangerouslySetInnerHTML is React’s replacement for using innerHTML in the browser DOM. In general, setting HTML from code is risky because it’s easy to inadvertently expose your users to a cross-site scripting (XSS) attack. So, you can set HTML directly from React, but you have to type out dangerouslySetInnerHTML and pass an object with a __html key, to remind yourself that it’s dangerous.

<tr dangerouslySetInnerHTML={{all}}><button type="submit" className="delete">Delete</button></tr>