React Render loop via map - passing extra parameters

Viewed 18

I have an API list of records that I render via map. I want to add an isEditAllowed flag to each record. How do I pass a value that is not part of the array? It doesn't change per record - it is just true/false for them all.

export default function UnitList({units, isEditAllowed}){
    
    return (
        <div>
            {units.map(unit) => (
                 <div key={unit.id}>
                     <UnitEditButton
                         id={unit.id}
                         isEditAllowed={isEditAllowed}
                     </>
                 </div>
...

How do I make isEditAllowed visible to the child component inside the iterations via map?

Currently, the <UnitEditButton> doesn't see any value for isEditAllowed.

0 Answers
Related