Não consegui idenficar onde estou errando
const [players,setPlayers] = useState([])
const newPlayer = (player)=>{
setPlayers([...players, player])
}
return (
<div className="App">
<Banner />
<Form times = {times.map(time => time.nome)} playerCadastrado={player => newPlayer(player)}/>
{times.map(time => <Time
key={time.nome}
nome={time.nome}
corPrimaria ={time.corPrimaria}
corSecundaria={time.corSecundaria}
players={players.filter(player => player.time === time.nome)}
/>)}
</div>
);
}
Player seria o component Colaborador
import Player from '../Player';
import './Time.css'
const Time = (props) => {
return(
<section className='time' style={{ backgroundColor: props.corSecundaria }}>
<h3 style={{ borderColor: props.corPrimaria }}>{props.nome}</h3>
<div className='players'>
{props.players.map(player => <Player nome={player.nome} funcao={player.funcao} imagem={player.imagem} />)}
</div>
</section>
)
}
export default Time;
Tenho o código completo em meu github: https://github.com/FelipeJorge/Organo-Project