How to set default value in Calendar

UI Components for React
Post Reply
mpprime
Posts: 4
Joined: 10 Apr 2016, 17:47

17 Jun 2020, 15:54

Hi.
I'm trying to put the default day into a Calendar component.
at the moment I set it fixed in the state:

Code: Select all

    this.state = {
            start: '18/06/2020'
        };
        
        
        <Calendar id="data_inizio" showIcon={true} value={this.state.start} required
                                          onChange={(e) => this.setState({start: e.value, minDate: e.value})}
                                          dateFormat="dd/mm/yy" monthNavigator={true} yearNavigator={true}
                                          yearRange="2020:2030" touchUI={true}/>
but the Calendar is always empty.

mert.sincan
Posts: 5281
Joined: 29 Jun 2013, 12:38

11 Oct 2020, 01:07

Hi,

Sorry for the delayed response! Could you please try to add it as a Date object to value property?

Best Regards,

snake pliskin
Posts: 2
Joined: 17 Feb 2021, 15:14

17 Feb 2021, 15:18

Hi mert.sincan!

Please, example

snake pliskin
Posts: 2
Joined: 17 Feb 2021, 15:14

18 Feb 2021, 10:48

hi!
i solved the problem.
just need to initialize useState with a Date object.
as you said. thanks for the tip.

mert.sincan
Posts: 5281
Joined: 29 Jun 2013, 12:38

06 May 2021, 22:57

You're welcome!

Best Regards,

Post Reply

Return to “PrimeReact”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 13 guests