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 :: fade in onscroll jquery 
Javascript :: javascript apply 
Javascript :: node js add new object to object array json 
Javascript :: component will unmount 
Javascript :: javascript keep scroll visible 
Javascript :: netlify page not found on refresh vuejs vue-router 
Javascript :: new line javascript string 
Javascript :: regex look behind 
Javascript :: optional function parameter javascript 
Javascript :: vue cli debugger 
Javascript :: jQuery DataTables Checkboxes 
Javascript :: How to add JSX elements in an array 
Javascript :: array remove last item 
Javascript :: extract text from a string javascript 
Javascript :: electron js production release Distributing 
Javascript :: UnhandledPromiseRejectionWarning: TypeError: Converting circular structure to JSON 
Javascript :: How to update one mongoose db 
Javascript :: require express server.js 
Javascript :: angular compnent 
Javascript :: name first letter uppercase 
Javascript :: strict mode 
Javascript :: react build size 
Javascript :: js validate mongodb id 
Javascript :: map in react 
Javascript :: react-data-table-component cell action stack overflow 
Javascript :: luxon plus 
Javascript :: react chartjs 2 
Javascript :: how to compare previous value with current in javascript 
Javascript :: how to check if string is valid jwt 
Javascript :: javascript forEach() method 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =