I'm a little unsure how to take the value showBtn and pass it into my <ListComponent />
Here's the code:
const listOptions = list.actionCollection
.map((option) => {
const showBtn = option.has(RENDER_BTN);
// tried to assign showBtn to a value that could be passed to component below
return option;
});
{listOptions.map((option) => (
<ListComponent option={option} key={option.key} />
))}
My check for showBtn is working fine (returning true or false) but I can't access showBtn outside of the map function. Obviously the map is checking through various values so some will be true & others false, so keeping the map syntax is important. Any suggestions would be appreciated!
option.showBtn = showBtn;is all you need. Of course you can also skip all that and use{list.actionCollection.map((option) =>(<ListComponent someProp={option.has(RENDER_BTN)} ))}