I am currently facing an issue where I am getting data from my API, and then I would like to manipulate the data to create an array called events which I can use to pass to my calendar. I am trying the following:
const createEvents = () => {
workouts.map((w)=> {
setEvents(...events,
{
id: w.id,
title: w.name,
date: w.dateOfWorkout
});
});
However I am getting the error where it states that it was expecting only 1 argument, but got 2 instead. Whilst googling, I came across this website (https://daveceddia.com/usestate-hook-examples/) which had an example very similar to the above. I define my events as follows:
const [events, setEvents] = useState([]);
What am I missing here? I am fairly new to react and TS/JS. I come from C# where in essence I am trying to do the equivalent of:
myData.Select(x => new {
Id = x.Id,
...
})
returnin your map for one thing.mapcallback is a common error in JavaScript.