Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CalendarList is not rendering the past months and the ones after January 2019 #425

Open
martinshhh opened this issue Apr 6, 2018 · 14 comments

Comments

@martinshhh
Copy link

Description

I have an <Agenda /> and when I open CalendarList it is not rendering the past months and the ones after January 2019. I can scroll but all it shows is a blank screen.
I also tried to define the <CalendarList /> without the agenda but the behaviour is the same.

Expected Behavior

To render every past month and the future ones

Agenda definition

             <Agenda
                    items={this.items}
                    // current={this.state.selectedDay}
                    loadItemsForMonth={this.loadItems.bind(this)}
                    //selected={'2017-05-16'}
                    ref={(agenda) => { this.agenda = agenda; }}
                    renderItem={this.renderItem.bind(this)}
                    renderEmptyDate={this.renderEmptyDate.bind(this)}
                    rowHasChanged={this.rowHasChanged.bind(this)}
                    onCalendarToggled={this.onCalendarToggled.bind(this)}
                    onDayChange={this.onDayChange.bind(this)}
                    onDayPress={this.onDayPress.bind(this)}
                    theme={{
                        height: 300,
                        selectedDayBackgroundColor: '#42B5A0',
                        textDayFontSize: 20,
                        arrowColor: 'black',
                        monthTextColor: 'black',
                        textMonthFontSize: 25,
                        textDayHeaderFontSize: 14,
                        textSectionTitleColor: '#42B5A0',
                        agendaKnobColor: '#42B5A0',
                        agendaKnobSize: 12,
                        'stylesheet.agenda.main': {
                            knobContainer: {
                                flex: 1,
                                position: 'absolute',
                                left: 0,
                                right: 0,
                                height: 19,
                                bottom: 0,
                                alignItems: 'center',
                            }
                        }
                    }}
                />

Environment

Android/iOS

simulator-screen-shot---iphone

@anoopmm
Copy link

anoopmm commented Apr 9, 2018

@xMaarf same issue here, did you get any solutions?

@martinshhh
Copy link
Author

@anoopmm Nop, nothing yet.
Does it shows from April 2018 to January 2019?

@anoopmm
Copy link

anoopmm commented Apr 9, 2018

@xMaarf yes same

@anoopmm
Copy link

anoopmm commented Apr 9, 2018

are you using react-navigation ?

@martinshhh
Copy link
Author

Yes and no, router-flux. Already tried to downgrade and everything but I get the same result.

@anoopmm
Copy link

anoopmm commented Apr 9, 2018

in my case it is working perfectly out side tab navigation (react-navigation). issue is inside tab navigation.

@martinshhh
Copy link
Author

@anoopmm same for me. If I use it in a component that is not defined in my router, it works fine.
Have you found any workaround for this?

@tigo0
Copy link
Contributor

tigo0 commented Apr 18, 2018

It seems like the issue is with initialScrollIndex and initialNumToRender that is 10 by default (I think). I managed to fix it by setting the initialNumToRender to the amount of months past + present and manually scrolling to the correct index after the component has been mounted.

  componentDidMount() {
      requestAnimationFrame(() => {
        this.listView.scrollToIndex({animated: false, index: this.getMonthIndex(this.state.openDate)});
      });
  }

  render() {
    return (
      <FlatList
        ref={c => this.listView = c}
        initialNumToRender={this.futureScrollRange + this.pastScrollRange + 1}
        ...CalendarListProps
      />
    );
  }

@chrismllr
Copy link

chrismllr commented May 2, 2018

@xMaarf Can you test out the fix at #474 to see if it fixes your issue? This looks like the exact issue I saw when I created it.

@MrHazimAli
Copy link

@chrismllr @tautvilas removing intialScrollIndex did not solve the problem.. still calendarList not showing date of month after january 2019 and past months. any solutions for this ?

@Ravim-addweb
Copy link

Any solutions for this yet?

@m00gl3
Copy link

m00gl3 commented Jan 6, 2019

Other than using #474 to fix this issue (manually) - is there any update on when this will be merged to the next version?

@damikdk
Copy link

damikdk commented Jan 22, 2019

I use horizontal CalendarList and got the same issue. Custom style was the problem:

theme={{
  'stylesheet.calendar.header': {
    header: { height: 0 },
  },
}}

delete this stylesheet.calendar.header solved it for me

UPD: sike. Months renders only on arrow press, but disappear on swipe :(

rodrigopk added a commit to freework-gmbh/react-native-calendars that referenced this issue Jul 26, 2019
Link: wix#425 (comment)
Fixed past months not being loaded due to limit of initialNumToRender prop on FlatList
@nathsimpson
Copy link
Contributor

I had a similar issue happen to me recently in an expo project. I solved it by updating the Expo SDK to the latest versions :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests