React-native-modal-datetime-picker: The initial date is reset after onCancel

Created on 18 Apr 2019  路  4Comments  路  Source: mmazzarolo/react-native-modal-datetime-picker

When setting an initial date date={initialDate} and then press the cancel button, the date and time are reset to "now".

bug

Most helpful comment

Thanks for reporting (even if you haven't followed the template! 馃懘 )
Looks like a bug related to this line.
I think it should be this.props.date instead of Date.now().
Willing to submit a PR and check if it fixes the issue?

All 4 comments

Thanks for reporting (even if you haven't followed the template! 馃懘 )
Looks like a bug related to this line.
I think it should be this.props.date instead of Date.now().
Willing to submit a PR and check if it fixes the issue?

This seems to work:
_resetDate = () => { this.setState({ date: this.props.date || new Date() }); };

@mmazzarolo sorry for don't follow the template. It was too much text 馃槥.
PR sent 馃殌

@basbase thanks for the snipet. I think || new Date() is not required since default props avoid date to be undefined.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DiegoDevBittencourt picture DiegoDevBittencourt  路  3Comments

gopikasireddy202 picture gopikasireddy202  路  3Comments

cgathergood picture cgathergood  路  5Comments

ketanpatel3377 picture ketanpatel3377  路  5Comments

pixsolution picture pixsolution  路  4Comments