Well you don't use a .map when you make this list was my point ;)
Good point on the remove - I'd do that by using a useCallback if I'd remembered lol:
functionApp4(){const[render,setRender]=useState(items)constremove=useCallback(_remove,[])return(<Box><ListclassName="App"><Repeatlist={render}><RenderItemremove={remove}/>
</Repeat>
</List>
<Buttonvariant="contained"color="primary"onClick={add}>Add</Button>
</Box>
)functionadd(){setRender((items)=>[{name:"Made up at "+Date.now(),on:false}...items,])}function_remove(item){setRender((items)=>items.filter((i)=>i!==item))}}
The index property is important for many things that require sorting etc and while the component will be called when you update the list it then shouldn't be creating a new element if the index stays stable (as I'm inserting at the top of the list that isn't likely)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Well you don't use a .map when you make this list was my point ;)
Good point on the
remove
- I'd do that by using auseCallback
if I'd remembered lol:The
index
property is important for many things that require sorting etc and while the component will be called when you update the list it then shouldn't be creating a new element if the index stays stable (as I'm inserting at the top of the list that isn't likely)