I am a beginner at React learning it from an online tutorial.
there is an element used in one of the courses which is ...
and can be seen in the following code
handleIncrement = (productId)=>{
const newProducts=[...this.state.products]
const index= newProducts.findIndex(p=> p.id === productId)
newProducts[index].count +=1 ;
this.setState({products : newProducts});
}
its usage seems to be creating an array from products
and passing it to the newProducts
which is an array now. could you please explain what exactly do ... and when we need it to use?