How to create a view for calendar in React, how will render the elements of an array as follows?

Viewed 36

28 29 30 31 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 1 2 3 4 5 6 7 8

I need this for a calendar component I'm making I need to get to the bottom line every 7 days.

2 Answers

I implemented this in React Native, idea is the same.

const days = [ 28,29,30,31,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,1,2,3,4,5,6,7,8];

return (
   <View
      style={{ flexDirection: "row", flexWrap: "wrap", marginVertical: 10 }}
    >
      {days.map((day) => (
        <View
          key={day}
          style={{
            width: `${100 / 7}%`,
            height: 20,
            justifyContent: "center",
            alignItems: "center"
          }}
        >
          <Text >{day}</Text>
        </View>
      ))}
    </View>
)

enter image description here

Related