So I am attempting to create a movie voting app for my friends and I. I have most of it set up in react and I cant figure out how to set/update the state of the 'rating' object.
The array is set up as follows:
import React, { useState, createContext } from 'react';
export const MovieListContext = createContext();
export const MovieListProvider = (props) => {
    const [movieList, setMovieList] = useState([
        {
            name: "Test",
            rating: ""
        },
        {
            name: "Testing",
            rating: ""
        },
        {
            name: "Tester",
            rating: ""
        },
    ]);
    return (
        <MovieListContext.Provider value={[movieList, setMovieList]}>
            {props.children}
        </MovieListContext.Provider>
    )
}
Then I want to be able to write over the array and update the rating object with each one of our ratings
import React, { useState, useContext } from 'react';
import Movie from './Movie'
import {MovieListContext} from "../MovieListContext";
import VotingCandidates from "./VotingCandidates";
const VotingForm = () => {
    const [movieList, setMovieList] = useContext(MovieListContext);
    
    const handleRatingChange = (e, movieList) => {
        setMovieList([...movieList, {rating: e.target.value}]);
        console.log(movieList)
    }
    return (
        <div>
            {movieList.map(movieList => (
                <li key={movieList.name}>{movieList.name}
                <input onChange={handleRatingChange} type="text"/>
                </li>
                
            ))}
            
            <button>VOTE</button>
        </div>
    )
}
export default VotingForm
I can't figure out a way to make it so the state of the movieList.rating objects are able to be updated
 
     
     
    