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

@types/react-datepicker

Package Overview
Dependencies
Maintainers
1
Versions
101
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/react-datepicker

TypeScript definitions for react-datepicker

  • 4.15.2
  • npm
  • Socket score

Version published
Weekly downloads
436K
decreased by-59.37%
Maintainers
1
Weekly downloads
 
Created

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

FAQs

Package last updated on 10 Oct 2023

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