New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-native-calenderpicker

Package Overview
Dependencies
Maintainers
0
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-calenderpicker

[![npm version](https://badge.fury.io/js/react-native-calendarpicker.svg)](https://badge.fury.io/js/react-native-calendarpicker) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/pr

latest
npmnpm
Version
1.1.5
Version published
Maintainers
0
Created
Source

npm version code style: prettier

CalendarPicker

A flexible and customizable React Native calendar picker component that supports both iOS and Android. This component allows single-date selection and date-range selection modes and is compatible with date-fns and moment libraries for seamless date manipulation.

Prerequisites

This project requires NodeJS (version 8 or later) and NPM.
Node and NPM are really easy to install.
To make sure you have them available on your machine, try running the following command.

Using npm:

$ npm install date-fns moment react-native-calendarpicker

Using Yarn:

$ yarn add date-fns moment react-native-calendarpicker

Example

Logo

Usage

Basic Example:

import React, { useState } from 'react';
import { View, Text, StyleSheet } from 'react-native';
import CalendarPicker from 'react-native-calendarpicker';

const App = () => {
  const [selectedDates, setSelectedDates] = useState({});

  const handleDateChange = (dates) => {
    setSelectedDates(dates);
  };

  return (
    <View style={styles.container}>
      <Text style={styles.title}>Select a Date or Date Range</Text>
      <CalendarPicker
        mode="range" // or "single"
        StartDate={null}
        EndDate={null}
        onChange={handleDateChange}
        height={40} // Adjust day cell vertical margin
      />
      <Text style={styles.output}>
        Selected Start Date: {selectedDates?.startDate?.format('DD/MM/YYYY') || 'N/A'}
      </Text>
      <Text style={styles.output}>
        Selected End Date: {selectedDates?.endDate?.format('DD/MM/YYYY') || 'N/A'}
      </Text>
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 16,
    justifyContent: 'center',
  },
  title: {
    fontSize: 20,
    fontWeight: 'bold',
    marginBottom: 16,
  },
  output: {
    marginTop: 8,
    fontSize: 16,
  },
});

export default App;
PropTypeDefaultDescription
onChangefunctionnullCallback function invoked when a date or range is selected.
modestring"single"Mode of selection. Options: "single" or "range".
StartDatestringnullThe initial start date in YYYY-MM-DD format.
EndDatestringnullThe initial end date (for range mode) in YYYY-MM-DD format.
previewbooleanfalseEnables a preview mode for displaying the selected dates.
heightnumber15Adjusts the vertical margin of day cells.

Additional Information

Dependencies:

This component requires date-fns and moment for date handling. Make sure to install them using the commands provided above.

Customization:

You can modify styles such as startDate, endDate, and inRange in the StyleSheet object to customize the UI.

Future Dates:

Future dates are automatically disabled and styled with a gray text color.

Navigation:

Month navigation buttons (next and previous) are included.

Contributions

Feel free to submit issues, feature requests, or pull requests. Feedback and contributions are always welcome to improve the library!

License

This project is licensed under the MIT License.

Enjoy using the CalendarPicker component for all your React Native calendar needs! 😊

Keywords

datetimepicker

FAQs

Package last updated on 27 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts