Sha256: 0ec734cb3fa1f723a26e573ab435989e2d9f38722d3cefe20b19153a634113ab

Contents?: true

Size: 860 Bytes

Versions: 61

Compression:

Stored size: 860 Bytes

Contents

import React, { useState } from 'react'
import { DatePicker, LabelValue } from '../..'

const DatePickerOnChange = () => {
  const today = new Date()
  const [dateString, setDateString] = useState(today.toLocaleDateString())
  const [dateObj, setDateObj] = useState([today])

  const changeHandler = (dateStr, selectedDates) => {
    setDateString(dateStr)
    setDateObj(selectedDates)
  }

  return (
    <div>
      <DatePicker
          defaultDate={dateString}
          marginBottom="lg"
          onChange={changeHandler}
          pickerId="date-picker-onchange"
      />
      <LabelValue
          label="Date Object"
          marginBottom="lg"
          value={dateObj[0] ? dateObj[0].toString() : ''}
      />
      <LabelValue
          label="Date String"
          value={dateString}
      />
    </div>
  )
}
export default DatePickerOnChange

Version data entries

61 entries across 61 versions & 1 rubygems

Version Path
playbook_ui-7.3.0.pre.alpha3 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-7.3.0.pre.alpha1 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-7.2.0 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-7.1.2 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-7.1.0.pre.alpha2 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-7.1.1.pre.alpha1 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-7.0.1 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-7.1.1 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-7.1.0.pre.alpha1 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-7.1.0 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-7.0.1.pre.alpha15 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-6.8.2.pre.alpha1 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-7.0.0.pre.alpha15 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-7.0.1.pre.alpha14 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-7.0.0.pre.alpha14 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-7.0.0.pre.alpha13 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-7.0.0.pre.alpha12 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-7.0.0 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-7.0.0.pre.alpha11 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-6.8.1 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx