Я новичок в React.
Я получаю массив записей из родительских данных и пытаюсь обновить данные записей с помощью setRecords. Есть ли способ обновить родительское состояние из дочернего состояния?
{
homeTeamName: "Blue"
homeTeamId: 1
homeScore: 1
awayTeamName: "Red"
awayTeamId: 2
awayScore: 1
scheduledAt: "2020-01-01T00:00:00"
location: "Fort Lee, NJ"
league: null
leagueId: 1
club: null
clubId: 1
matchRecords: Array(4)
0: {scoreMemberId: 2, scoreMemberName: "Jake Kwon2", scoreTeamId: 1, assistMemberId: 1, assistMemberName: "Jake Kwon1", …}
1: {scoreMemberId: 1, scoreMemberName: "Jake Kwon1", scoreTeamId: 1, assistMemberId: 2, assistMemberName: "Jake Kwon2", …}
2: {scoreMemberId: 3, scoreMemberName: "Jake Kwon3", scoreTeamId: 2, assistMemberId: 4, assistMemberName: "Jake Kwon4", …}
3: {scoreMemberId: 4, scoreMemberName: "Jake Kwon4", scoreTeamId: 2, assistMemberId: 3, assistMemberName: "Jake Kwon3", …}
}
const RecordItem = ({ record, teamId, memberOptions, isAdmin }) => {
const [records, setRecords] = useState(record);
const { scoreMemberId, scoreMemberName, assistMemberId, assistMemberName } = records;
useEffect(() => {
setRecords(record)
}, [record]);
<CustomDropdown
name='member'
value={scoreMemberId}
handleChange={member => setRecords({ ...records, scoreMemberId: member.value })}
options={memberOptions.filter(member => member.teamId === teamId)}
required
/>