The update of the react component data in the list list triggers all list data changes rather than the corresponding item data changes

has the following structure

that.state.list.map(function(item,index){
    return (
    
        <li>{}
        {this.state.show?
            <DetailComponent data={this.state.date}/>
        :null
        }
        </li> (index )
    )
})


probably such a structure is to request the data to show the DetailComponent details in the corresponding subscript li every time I click on li. When I show multiple li at the same time, why all the li detail data will be turned into the last detail data I opened. DetailComponent is also a loop rendering dom structure

.
Mar.05,2021

because the data of your DetailComponent comes from state. Clicking on li,state will change, and there will be a unified re-render for Synchronize, a component that applies state.

if you want each click to be different, you can create a new array in state. And then through map li to achieve.
like this:

arr.map((item, index)=>{
    <li>item.date</li>
})

you need to record the item.id you currently clicked in state.

that.state.list.map(function(item,index){
    return (
    
        <li onClick={() => this.setState({selectedId: item.id})}>{}
        {this.state.selectedId === item.id?
            <DetailComponent data={this.state.date}/>
        :null
        }
        </li> (index )
    )
})
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b2285a-2b61d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b2285a-2b61d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?