So I have been trying for days to solve the following issue:
movies [
{
id: 1,
name: 'Alpha',
rating: 0
},
{
id: 2,
name: 'Bravo',
rating: 0
},
{
id: 3,
name: 'Charlie',
rating: 0
}
]
I already have a way to add and delete movies to/from this array but I want to have an input section for each item where the rating state will be updated to the input's value. I have been using 'useReducer' to assist with this but I guess I'm just not sure of the syntax/what would be the payload?
I know there is a way to do movies.map(movie=> {etc.etc.} but I can't seem to figure it out. Help is greatly appreciated.
EDIT:
<div>
{movies.map(movie => (
<h1>{movie.name}</h1>
<input placeholder={movie.rating}
onChange={//I WANT THE MOVIE.RATING TO CHANGE ON INPUT CHANGE//}
/>
))}
</div>
I want the output to look something like this, where the state of the {movie.rating} object is updated on input change
{movie.name}
))}