GithubHelp home page GithubHelp logo

trendingtechnology / rnv-date-range-picker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dilipchandima/rn-select-date-range

0.0 0.0 0.0 675 KB

A simple and fully customizable React Native date range picker component

Home Page: https://www.npmjs.com/package/rnv-date-range-picker

License: MIT License

JavaScript 45.49% Starlark 2.73% Java 28.10% Ruby 3.31% Objective-C 20.37%

rnv-date-range-picker's Introduction

rnv-date-range-picker

A simple React Native date range picker component


Installing:

npm install rnv-date-range-picker

or

yarn add rnv-date-range-picker

Screenshot

screen gif

screen shot

Prerequisites

CalendarPicker requires Moment JS.

npm install --save moment

Example

import moment from "moment";
import React, { useState } from "react";
import { SafeAreaView, StyleSheet, View, Text } from "react-native";
import DateRangePicker from "rnv-date-range-picker";

const App = () => {
  const [selectedRange, setRange] = useState({});
  return (
    <SafeAreaView>
      <View style={styles.container}>
        <DateRangePicker
          onSelectDateRange={(range) => {
            setRange(range);
          }}
          responseFormat="YYYY-MM-DD"
          maxDate={moment()}
          minDate={moment().subtract(100, "days")}
        />
        <View style={styles.container}>
          <Text>first date: {selectedRange.firstDate}</Text>
          <Text>second date: {selectedRange.secondDate}</Text>
        </View>
      </View>
    </SafeAreaView>
  );
};

const styles = StyleSheet.create({
  container: {
    margin: 50,
  },
});

export default App;

CalendarPicker Props

Prop Type Description
maxDate Moment() Optional. If you need to pass Max Date user can select, set this prop as a moment date
minDate Moment() Optional. If you need to pass Min Date user can select, set this prop as a moment date
responseFormat String Optional. Please refere the date formats here Moment Date Formats
onSelectDateRange Method This will return a object with firstDate and lastDate

onSelectDateRange response

{
    firstDate: if you pass responseFormat it will be a formatted date, if not it will be a moment date
    lastDate: if you pass responseFormat it will be a formatted date, if not it will be a moment date
}

Run the sample app

cd example
npm install
npx react-native run-ios

Suggestions?

Open Issues. Submit PRs.

rnv-date-range-picker's People

Contributors

dilipchandima avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.