🚀 Launch Week Day 4:Introducing the Alert Details Page: A Better Way to Explore Alerts.Learn More →
Socket
Book a DemoInstallSign in
Socket

react-date-field

Package Overview
Dependencies
Maintainers
3
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-date-field

React DateField

Source
npmnpm
Version
0.2.2
Version published
Weekly downloads
164
82.22%
Maintainers
3
Weekly downloads
 
Created
Source

react-date-field

React DateField

Input integration for react-date-picker.

Install

$ npm i --save react-date-field

Usage


import DatePicker from 'react-date-picker'
import DateField from 'react-date-field'

import 'react-date-picker/index.css'

let value = ...

<DateField>
  <DatePicker date={value} onChange={this.onChange} />
</DateField>

For the basic setup, you don't need to configure the DateField with any additional props. Only render a DatePicker inside it.

Props

  • displayFormat: String - the display in which dates will be displayed in the input. If none specified, the dateFormat from DatePicker will be used.
  • renderInput: Function - you can use the renderInput function to render your own input field. This function will be called with all the necessary props to render the input. You can change the props, and return undefined to allow the default rendering logic go through, or you can return something different than undefined to render whatever you want. By default, the field that will be rendered is readOnly
  • clearIcon: Boolean/ReactNode - Defaults to true. If false, no clear icon will be rendered. If a ReactNode is specified, it will be rendered.
  • renderClearIcon: Function - a function to render a custom clear icon.
  • renderCalendarIcon: Function - a function to render a custom calendar icon.
  • expandOnFocus: Boolean - defaults to true.
  • collapseOnChange: Boolean - defaults to true.
  • expanded: Boolean - if you want to control the expanded prop (when this is true, the picker is visible). Generally you won't need to specify this.
  • defaultExpanded: Boolean - defaults to false. Uncontrolled version of expanded
  • onFocus: Function
  • onBlur: Function

You don't have an onChange prop on the DateField. Instead, use the onChange you specify on the DatePicker.

If you render a <DateField /> with a clear icon, when the user clicks the icon, the onChange function of the picker will be called like onChange('', null, event) - dateText as empty string, moment instance as null and the additional event.

Note

Please use react-date-field with the latest version of react-date-picker. Inside the field, you need to render the picker, which only works correctly if the picker has a default prop isDatePicker: true. This means you could provide your own date picker, as long as it has such a property and it exposes the same signature to the onChange prop/method.

License

MIT

Keywords

date

FAQs

Package last updated on 06 Jan 2016

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