Skip to content

Commit

Permalink
Calendar demo screen - move items load to componentDidMount
Browse files Browse the repository at this point in the history
  • Loading branch information
Inbal-Tish committed May 22, 2023
1 parent 08c9fc8 commit f41adf1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ export default class CalendarScreen extends Component {
showLoader: false
};

constructor(props: any) {
super(props);
componentDidMount(): void {
this.loadEvents(this.state.date);
}

Expand Down
5 changes: 4 additions & 1 deletion src/incubator/Calendar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function Calendar(props: PropsWithChildren<CalendarProps>) {
setHeaderHeight,
headerHeight
};
}, [processedData]);
}, [processedData, staticHeader, showExtraDays, firstDayOfWeek]);

/** Pages reload */

Expand Down Expand Up @@ -135,6 +135,7 @@ function Calendar(props: PropsWithChildren<CalendarProps>) {
const index = getItemIndex(selected);

if (shouldAddPages(index)) {
console.log('Add new pages');
runOnJS(addPages)(index);
} else if (lastUpdateSource.value !== UpdateSource.MONTH_SCROLL) {
if (previous && !isSameMonth(selected, previous)) {
Expand All @@ -143,6 +144,8 @@ function Calendar(props: PropsWithChildren<CalendarProps>) {
}
}, [getItemIndex]);

/** Events */

const onViewableItemsChanged = useCallback(({viewableItems}: any) => {
const item = viewableItems?.[0]?.item;
if (item && scrolledByUser.value) {
Expand Down

0 comments on commit f41adf1

Please sign in to comment.