React is not inserted into the tag after traversal.

ListItems has declared
in state that the following code is called in successfully getting the interface data success

that.state.ListItems = that.state.dataList.map(item => (
          <div className="list" key={item.goodsID}>
            <img src={item.goodsListImg} alt="" />
            <div className="detail">
              <div className="title">{item.goodsName}</div>
              <div className="price">
                <span>{item.price}</span>
              </div>
            </div>
          </div>
        ));
        console.log(that.state.ListItems);//


render

  render() {
    return (
      <div className="hot">
        <div id="mescroll" className="mescroll">
          {this.state.ListItems}
        </div>
      </div>
    );
  }

I wonder if my way of dynamic rendering is correct

Apr.02,2021

state as a dom tag, the only function that changes in react is that this.setState, can render


completely wrong. Please read the document to learn, do not invent by yourself


 <div className="hot">
    <div id="mescroll" className="mescroll">
      {this.state.ListItems ? this.creatDom(this.state.ListItems):null}
    </div>
  </div>

creatDom(data){
    return (
      data.map((item) => {
        return (
            <div className="list" key={item.goodsID}>
                <img src={item.goodsListImg} alt="" />
                <div className="detail">
                  <div className="title">{item.goodsName}</div>
                  <div className="price">
                    <span>{item.price}</span>
                  </div>
                </div>
              </div>
        )
      })
    )
}
Menu