Cannot read properties of undefined (reading 'isValidate')

Offen
#928 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
45/100
Issue-Typ
Bug
Klarheit
Muss geklärt werden
Aktivitätsstatus
Aktiv
Tech-Stack
javascript, react
Bereich
frontend

Rechercherichtung

Beginne damit, das bereitgestellte rc-picker-Beispiel mit rc-picker 4.11.3, dayjs 1.11.5 und React 18.2.0 zu reproduzieren. Verfolge den Stack durch useFieldsInvalidate und die Day.js-Integration, wobei die gezeigte TimePicker-Komponente als Einstiegspunkt dient. Als abgeschlossen gilt die Aufgabe, wenn der TimePicker gerendert wird und die Auswahl ohne den isValidate TypeError verarbeitet.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Cannot read properties of undefined (reading 'isValidate')
TypeError: Cannot read properties of undefined (reading 'isValidate')

    at Object.current (http://localhost:3000/static/js/vendors-node_modules_dayjs_plugin_isSameOrAfter_js-node_modules_dayjs_plugin_isSameOrBefore_j-8f3d56.chunk.js:9228:21)
    at http://localhost:3000/static/js/vendors-node_modules_dayjs_plugin_isSameOrAfter_js-node_modules_dayjs_plugin_isSameOrBefore_j-8f3d56.chunk.js:14134:114
    at http://localhost:3000/static/js/vendors-node_modules_dayjs_plugin_isSameOrAfter_js-node_modules_dayjs_plugin_isSameOrBefore_j-8f3d56.chunk.js:8996:22
    at Array.map (<anonymous>)
    at http://localhost:3000/static/js/vendors-node_modules_dayjs_plugin_isSameOrAfter_js-node_modules_dayjs_plugin_isSameOrBefore_j-8f3d56.chunk.js:8978:30
    at mountMemo (http://localhost:3000/static/js/bundle.js:165672:23)
    at Object.useMemo (http://localhost:3000/static/js/bundle.js:166057:20)
    at Object.useMemo (http://localhost:3000/static/js/bundle.js:191308:25)
    at useFieldsInvalidate (http://localhost:3000/static/js/vendors-node_modules_dayjs_plugin_isSameOrAfter_js-node_modules_dayjs_plugin_isSameOrBefore_j-8f3d56.chunk.js:8977:62)
    at Picker (http://localhost:3000/static/js/vendors-node_modules_dayjs_plugin_isSameOrAfter_js-node_modules_dayjs_plugin_isSameOrBefore_j-8f3d56.chunk.js:8351:101)

rc-picker v.4.11.3
"dayjs": "^1.11.5",
"react-dom": "^18.2.0",
"react": "^18.2.0",

import React, { useState } from 'react'

import dayjs from 'dayjs'
import customParseFormat from 'dayjs/plugin/customParseFormat'
import isSameOrAfter from 'dayjs/plugin/isSameOrAfter'
import isSameOrBefore from 'dayjs/plugin/isSameOrBefore'
import Picker from 'rc-picker'
import 'rc-picker/assets/index.css'
import enUS from 'rc-picker/lib/locale/en_US'

dayjs.extend(customParseFormat)
dayjs.extend(isSameOrAfter)
dayjs.extend(isSameOrBefore)

const TimePicker = ({ currentCompany }) => {
  const defaultValue = dayjs() 

  const [value, setValue] = useState(defaultValue)

  const onSelect = newValue => {
    if (newValue && dayjs.isDayjs(newValue)) {
      console.log('Select:', newValue)
    }
  }

  const onChange = newValue => {
    if (newValue && dayjs.isDayjs(newValue)) {
      console.log('Change:', newValue)
      setValue(newValue)
    }
  }

  const sharedProps = {
    value: value || defaultValue,
    onSelect,
    onChange
  }

  return (

    <div className='App'> 
       <h3>RC Time Picker with DayJS</h3>
      <Picker
        mode='time'
        {...sharedProps}
        locale={enUS}
        defaultValue={defaultValue}
        format='HH:mm' // Define how the date should be displayed
      />
      <div style={{ marginTop: 20 }}>
        <p>
          Selected Date:{' '}
          {value
            ? value.format('YYYY-MM-DD')
            : defaultValue.format('YYYY-MM-DD')}
        </p>
      </div>
    </div>

  )
}

export default TimePicker
Vorherrschende Sprache
TypeScript
Sterne
306
Forks
356
Ø Merge
1 Std. 42 Min.
Gemergte PRs (30 T.)
1

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus react-component/picker

Alle Issues in react-component/picker

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.