Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-persian-dates

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-persian-dates

>

  • 1.0.10
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

react-persian-dates

NPM JavaScript Style Guide

Install

npm install --save react-persian-dates

Usage

import React, { Component } from 'react'

import Datepicker from 'react-persian-dates'

class Example extends Component {
  render () {
    return (
      <Datepicker
        onSelect={this.handleChange}
      />
    )
  }
}

Props

Props nameDesciptionValuesDefault value
monthsCountNumber of months shown in date picker(Number)12
startDateThe date that calendar use to start generating(Date)new Date()
selectFromThe date that is marked when date picker appears(Date)new Date()
selectToThe date that is marked as second date (usable in range date picker)(Date)null
onSelectFunction that returns a value when marked dates are changed in date picker(Function)null
rangeSelectSpecify if date picker is single or range(Boolean)false
scrollToSelectedDayA function that returns the selected date element. (#1. Refer to examples) (#2. You can use it for scrolling to selected day)(Function)undefined

Example

import React, { Component } from 'react'

import Datepicker from 'react-persian-dates'

class Example extends Component {
  constructor(props) {
    super(props);
    this.state = {
      from: new Date(),
      to: null,
    };
  }
  
  handleChange = value => {
    this.setState({
      from: value.from,
      to: value.to,
    });
  };
  
  render () {
    const { from, to } = this.state;
    return (
      <Datepicker
        rangeSelect={true}
        startDate={new Date()}
        selectFrom={from}
        selectTo={to}
        onSelect={this.handleChange}
        scrollToSelectedDay={day =>
          setTimeout(
            () =>
              window.scrollTo({
                top: day.offsetTop - 200,
                left: 0,
                behavior: 'smooth',
              }),
            500,
          )
        }
      />
    )
  }
}

License

MIT © majid-amiri

FAQs

Package last updated on 07 Aug 2019

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc