Topic: MDBDatePicker props

drclohite pro asked 3 years ago


*_Expected behavior_*I am trying to transfer a suggested date in through props, so that the datepicker starts on that date if it has been preselected. The date comes from the database.

*_Actual behavior_*I just get today's date every time. I am not actually passing the date for some reason either. the console out, shows {} empty. I can change the parent getpickervalue to what?

*_Resources (screenshots, code snippets etc.)_*Parent code:

import TargetDate from './targetDate'

<... Date2Context.Provider value={{ state2, dispatch2 }}...> <...TargetDate value="2020-06-27T21:44:00.000Z"/...> <.../Date2Context.Provider...>

Component code: './targetDate'import React, { useContext } from 'react';import { Date2Context } from './todos.js'import { MDBDatePicker } from 'mdbreact';

function DatePickerPage(props) {console.log('datesent:',props) const {state2, dispatch2} = useContext(Date2Context); const changeInputValue = (newValue) => { dispatch2({ type: 'UPDATE_INPUT', data: newValue,}); }; return( changeInputValue(e)}/> );};

export default DatePickerPage;


Piotr Glejzer staff commented 3 years ago

This code doesn't help me :(


drclohite pro answered 3 years ago


This is how I import datapicker into the React application: import { MDBDatePicker } from 'mdbreact';


drclohite pro answered 3 years ago


I run date-picker. I can pick a date and when picked it shows in the field with the appropriate data and I can store that date to my database. When I review the record again where the date is stored, I would like to load the stored date into the date picker field for UI purposes, otherwise, it would look like the date field is not set, unless I created another field to show it which would not be a very good UI. So initially I get date from datepicker, then later I would like to post date to datepicker. Usually in react you would use props. I don't know the fieldname to use props, what is the fieldname, or can you elaborate on how to set the date in the datepicker to the value of the previously set date.



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Pro
  • Premium support: No
  • Technology: MDB React
  • MDB Version: 4.27.0
  • Device: PC
  • Browser: Chrome
  • OS: Windows 10
  • Provided sample code: No
  • Provided link: No
Tags