“React-DatePicker” Kod odpowiedzi

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
Abhishek

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}
    />
  );
};
Panicky Pony

Odpowiedzi podobne do “React-DatePicker”

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu