Is there a way to dynamically apply a background color to only the first 5 div blocks in React? Here is my code snippet:
const ImageBlock = ({block}) => {
const number = 5
return (
<React.Fragment>
{block.map((item, index) => {
return (
<div
key={index}
style={{
borderStyle: 'solid',
borderWidth: '2px',
backgroundColor: number ? "#000" : null,
}}
>
{item}
</div>
);
})}
</React.Fragment>
);
};