@React Datepicker
A simple datepicker for react/typescript component.
You can set an id, name, placeholder, a onChange callback, className and a preselected value via props.
Installation
The package can be installed via npm or yarn:
npm install @sankarbala/datepicker
yarn add @sankarbala/datepicker
Usage
import React, { useState } from "react";
import { DatePicker } from "@sankarbala/datepicker";
const MyForm = ({ data }) => {
const [date, setDate] = useState("01/02/2023");
const handleInputChanged = ({ e }) => {
setDate(e.target.value);
};
<DatePicker
id="birthday"
name="birthday"
onChange={handleInputChanged}
value={date}
className="form-control"
/>;
};
Props
id : an optional id for the datepicker (optional:string)
name : an optional name for the datepicker (optional:string)
placeholder : a placeholder string (optional:string)
value : set the value of the datepicker input (optional:date)
onChange : a callback function that takes as argument (target:func)
className : an optional attribute for the datepicker (optional:string)
disabled : an optional attribute for the datepicker (optional:boolean)
otherAttributes : an optional attribute for object of the rest attributes the datepicker (optional:object)