React-native-calendars: How to show current month's name in Agenda component

Created on 10 Mar 2019  路  17Comments  路  Source: wix/react-native-calendars

Is there a way of showing the current month when the component is in Agenda mode? Showing only the week of the currently selected day is not enough to give the proper context to the user, in my opinion.

stale

Most helpful comment

Hi,

I've achieved this issue using onDayPress props and moment.

<Text>{this.state.currentMonth}</Text>
<Agenda
 .......
 onDayPress={this.onUpdateSelectedDate}
/>
onUpdateSelectedDate(date) => {
  this.setState({ currentMonth: `${moment(date.dateString).format('MMMM')}` })
}

All 17 comments

I am assuming you are asking that if I have the week of 3/10 - 3/16 selected, you'd like to see agenda items that extend beyond these dates?

No, sorry, just re-read my comment and it wasn't clear enough. I meant the name of the month of the selected day.

Are you trying to have it render with the header?? I know you could use the renderDay prop to create your own 'day' component. Then include the month that way. Haven't found a way to modify the weekly header...

Yeah, I don't know if as a header, as you can put the whole component within a navigation stack, but definitely I think it lacks a way of showing the current month somewhere, either on the component where you can select a day, or grouping the days in the list, as iOS does in its native calendar.

This is exactly what I need too. Is there any solution yet for this?

I have the same issue ..any progress on this ?

I tried a couple of tricks to show only the month in the header but no success yet :< Any help is still appreciated.

Hi,

I've achieved this issue using onDayPress props and moment.

<Text>{this.state.currentMonth}</Text>
<Agenda
 .......
 onDayPress={this.onUpdateSelectedDate}
/>
onUpdateSelectedDate(date) => {
  this.setState({ currentMonth: `${moment(date.dateString).format('MMMM')}` })
}

@JordanProtin Very nice and practical solution. Then, how can you hide the header. It takes a lot of space and not very necessary in my case.

@afacar Something like this ?

<Agenda
  .......
  theme={{
    'stylesheet.calendar.header': {
      header: {
        height: 0
      },
      week: {
        height: 0
      }
    }
  }}
/>

@JordanProtin I tried but it doesn't hide the header :/

@afacar I see this feature is not implemented.. Currently, you should use this header using agenda component..

how did you put 2 components {this.state.currentMonth}
.......
onDayPress={this.onUpdateSelectedDate}
/>
in the same return statement?

i've wraped them in still not working

Hi, just you need to delete monthFormat.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@afacar Something like this ?

<Agenda
  .......
  theme={{
    'stylesheet.calendar.header': {
      header: {
        height: 0
      },
      week: {
        height: 0
      }
    }
  }}
/>

But if the user change month while scrolling, this month state will not change.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

filippoitaliano picture filippoitaliano  路  3Comments

Yandamuri picture Yandamuri  路  4Comments

microwin168 picture microwin168  路  4Comments

moiiiiit picture moiiiiit  路  4Comments

AleksandrZhukov picture AleksandrZhukov  路  3Comments