1.0.1 • Published 2 years ago

react-native-month-view-calendar v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

React Native Month View Calendar

Install

npm install --save react-native-month-view-calendar

Basic usage

import React from 'react';
import { MonthViewCalendar } from 'react-native-month-view-calendar';
import { View, ScrollView } from 'react-native'

const Component = () => {
  const eventsForCalendar = [
  	{
  	  title: 'My awesome event',
  	  date: new Date(),
  	},
  ];

  return (
    <ScrollView>
      <MonthViewCalendar
        cellStyles={{ minHeight: 65 }}
        events={eventsForCalendar}
        renderEvent={(event, i) => {
          return (
            <Text key={i} numberOfLines={1}>{event.title}</Text>
          )
        }}
      />
    </ScrollView>
  );
}

Props

PropertiesDefaultDescription
datenew Date()Date from which the calendar will be built
dayTextStyles{}Styles for label day(numer of day), can be array or object
eventsArray of events
headerTextStyles{}Styles for label week day name, can be array or object
cellStyles{}Styles for all cells
pastMonthsCellStyles{}Styles for all cells from past dates
weekDays'S', 'M', 'T', 'W', 'T', 'F', 'S'Array with name of the day of the week
renderEventFunction required to render event information. Example (event, index) =>
onSwipeCallback when calendar is swiped
onSwipePrevCallback when calendar is swiped to previous month
onSwipeNextCallback when calendar is swiped to next month
onScrollToIndexFailedCallback to handle errors on swipe

Methods

To use the component methods save a reference to it:

const reference = useRef();

<MonthViewCalendar
  ref={reference}
/>
  • goToDate(date): the component navigates to a custom date, date variable must be an instance of Date. Example: reference.current.goToDate(new Date());
  • getCurrentDate() returns current date that being displayed

Event object

{
  /// your props
  date: new Date(),
}
1.0.1

2 years ago

1.0.0

3 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago