react-native-datepicker icon indicating copy to clipboard operation
react-native-datepicker copied to clipboard

Datepicker date re-render.

Open pablodance opened this issue 6 years ago • 3 comments

Issue

We have setup the datepicker as follows:

<DatePicker
                  style={{width: 200, fontSize:22}}
                  date={this.state.datetime}
                  mode="datetime"
                  format="DD-MM-YYYY HH:mm"
                  confirmBtnText="Confirm"
                  cancelBtnText="Cancel"
                  iconSource={require('../../images/icons/ico-calendar.png')}
                  customStyles={{
                    dateIcon: {
                      position: 'absolute',
                      left: 0,
                      top: 4,
                      marginLeft: 0
                    },
                    dateInput: {
                      marginLeft: 20,
                      borderWidth:0,
                      paddingLeft:0,
                      marginTop:0
                    }
                  }}
                  minuteInterval={10}
                  onDateChange={(datetime) => {this.setState({datetime: datetime});}}
                />`
```

We have the above implementation of datepicker within a report form.   The (**this.state.datetime)** state is linked to a redux state.  The initial state (**this.state.datetime)** is set as current date / time in the constructor method.

The process is to complete the form and press submit (where a report time /date is selected and stored)- the form is then sent to the server and the form component is then removed and a completed component displayed - which shows the committed data and contains an edit button.

If we press the edit button - for some reason **the date={this.state.datetime}** reverts to the current date / time and not (**this.state.datetime)** value.  We can see that (**this.state.datetime)** is the correctly saved data - but for some confusing reason it does not update.  However when updating the date the **onDateChange**  function is updating the (**this.state.datetime)** value and the displayed value alters.  

Can anyone shine any light / offer any advice please?



pablodance avatar May 29 '19 15:05 pablodance

@pablodance any update on this?

gilsonviana avatar Aug 23 '19 14:08 gilsonviana

same issue here

ConnectedReasoning avatar Oct 13 '19 19:10 ConnectedReasoning

Same here, any solution ?

nelsondavidmi avatar Feb 27 '21 20:02 nelsondavidmi