I am trying to loop through an array of objects and each has an id constructed by uuidv4(), so it is a string. But typescript yells at us that (( Type 'String' is not assignable to type 'Key | null | undefined')). By the way, the type (( Key )) is itself of type (( String | number )) in its source code. If you are interested this is my code for the map method.
interface goal{
id: String;
title: String;
importance: number;
expDate: Date;
minorGoal?: minorGoal[];
}
goals.map(
(goal: goal) => (
<SinglePurpose
key={goal.id}
goal={goal}
/>
))
I tried to do it with ( index ) and pass it to the key but it caused other problems. I tried to rewrite the type ( Key ) and it didn't work.
I literally tried everything I found on the internet and non of them worked.