Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

react-datepicker

// npm install react-datepicker --save


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

function App () {
  const [selectedDate, setSelectedDate] = useState(null)
  return (
    <div className='App'>
      <DatePicker
        selected={selectedDate}
        onChange={date => setSelectedDate(date)}
        placeholderText={'dd/mm/yyyy'}
        filterDate={date => date.getDay() !== 6 && date.getDay() !== 0} // weekends cancel
        showYearDropdown // year show and scrolldown alos
        scrollableYearDropdown
      />
    </div>
  )
}

export default App
Comment

react datepicker

npm install react-datepicker --save
Comment

react-datepicker

npm install react-datepicker --save
Comment

react date picker

import { registerLocale, setDefaultLocale } from  "react-datepicker";
import es from 'date-fns/locale/es';
registerLocale('es', es)

<DatePicker
  locale="es"
/>
Comment

react datepicker documentation

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

react-datepicker

() => {
  const [startDate, setStartDate] = useState(new Date());
  const MyContainer = ({ className, children }) => {
    return (
      <div style={{ padding: "16px", background: "#216ba5", color: "#fff" }}>
        <CalendarContainer className={className}>
          <div style={{ background: "#f0f0f0" }}>
            What is your favorite day?
          </div>
          <div style={{ position: "relative" }}>{children}</div>
        </CalendarContainer>
      </div>
    );
  };
  return (
    <DatePicker
      selected={startDate}
      onChange={(date) => setStartDate(date)}
      calendarContainer={MyContainer}
    />
  );
};
Comment

PREVIOUS NEXT
Code Example
Javascript :: js access array value if exist 
Javascript :: understanding currying 
Javascript :: string literals 
Javascript :: working with multiple db in single query mongodb 
Javascript :: postgresql json array contains 
Javascript :: objects in javascript 
Javascript :: async await map 
Javascript :: js map on object 
Javascript :: react admin 
Javascript :: js autocomplete 
Javascript :: how to count characters 
Javascript :: convert json to dart 
Javascript :: .default in javascript 
Javascript :: node js + mongoose 
Javascript :: string en javascript 
Javascript :: how to generate a random number between certain values 
Javascript :: react and node js sample project github 
Javascript :: crud application in mean stack 
Javascript :: js match emoticon 
Javascript :: alert on right click jquery 
Javascript :: angular set dist output directly under dist rather than dist/project 
Javascript :: google-maps-react give undefined lat long 
Javascript :: queryselect get type of elment class or id 
Javascript :: react algoliasearch 
Javascript :: discord.js blank field 
Javascript :: how to make random responses 
Javascript :: next js newsletter 
Javascript :: what is the difference between angular changedetection default and onpush stratergy 
Javascript :: what is download api javascript 
Javascript :: remove or replacing element array in javascript 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =