Socket
Socket
Sign inDemoInstall

@types/react-datepicker

Package Overview
Dependencies
15
Maintainers
1
Versions
100
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @types/react-datepicker

TypeScript definitions for react-datepicker


Version published
Weekly downloads
1.1M
decreased by-11.18%
Maintainers
1
Install size
24.3 MB
Created
Weekly downloads
 

Package description

What is @types/react-datepicker?

The @types/react-datepicker package provides TypeScript definitions for the react-datepicker package. This allows developers using TypeScript to integrate the react-datepicker component into their projects with type checking, ensuring that props and options passed to the react-datepicker components are of the correct type. This enhances development experience by providing autocompletion and preventing common type-related errors.

What are @types/react-datepicker's main functionalities?

Basic Date Selection

This feature allows users to select a single date. The DatePicker component is imported from react-datepicker, and its selected and onChange props are used to manage the selected date state.

import React, { useState } from 'react';
import DatePicker from 'react-datepicker';
import 'react-datepicker/dist/react-datepicker.css';

function App() {
  const [startDate, setStartDate] = useState(new Date());
  return (
    <DatePicker selected={startDate} onChange={(date) => setStartDate(date)} />
  );
}

Date Range Selection

This feature enables users to select a range of dates. The DatePicker component's selectsRange prop is set to true, and the startDate and endDate props are used to manage the range of selected dates.

import React, { useState } from 'react';
import DatePicker from 'react-datepicker';
import 'react-datepicker/dist/react-datepicker.css';

function App() {
  const [startDate, setStartDate] = useState(new Date());
  const [endDate, setEndDate] = useState(new Date());
  return (
    <DatePicker
      selected={startDate}
      onChange={(dates) => {
        const [start, end] = dates;
        setStartDate(start);
        setEndDate(end);
      }}
      startDate={startDate}
      endDate={endDate}
      selectsRange
    />
  );
}

Custom Date Format

This feature allows the display format of the selected date to be customized using the dateFormat prop.

import React, { useState } from 'react';
import DatePicker from 'react-datepicker';
import 'react-datepicker/dist/react-datepicker.css';

function App() {
  const [startDate, setStartDate] = useState(new Date());
  return (
    <DatePicker
      selected={startDate}
      onChange={(date) => setStartDate(date)}
      dateFormat='yyyy/MM/dd'
    />
  );
}

Other packages similar to @types/react-datepicker

Readme

Source

Installation

npm install --save @types/react-datepicker

Summary

This package contains type definitions for react-datepicker (https://github.com/Hacker0x01/react-datepicker).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-datepicker.

Additional Details

Credits

These definitions were written by Rajab Shakirov, Greg Smith, Roy Xue, Koala Human, Justin Grant, Avi Klaiman, Naoki Sekiguchi, Kerry Gougeon, Shiftr Tech SAS, Pirasis Leelatanon, Alexander Shipulin, and Rafik Ogandzhanian.

FAQs

Last updated on 11 Mar 2024

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc