how to update nested state in reactjs, such as I have an Array of an object of course
state = {
courses: [
{ id: 1, coursename: "CSS3", like: 25, dislike: 0 },
{ id: 2, coursename: "Javascript", like: 45, dislike: 0 },
{ id: 3, coursename: "ReactJS", like: 294, dislike: 0 }
]
};
now i want to update like on the particular course only on onClick , after updating it should be 26 . and again if i click it should decremented by 1.
- You can find the code in codesandbox