Hello friends, I'm using "react-native-modal-datetime-picker": "^9.1.0" on android and it's not showing on release mode, debug mode works fine. Some info about my code: I'm using function component to render the dateTimePicker and importing it in another component. This is a code example:
DateTimePickerComponent:
export default DatePickerButton = ({selectedDate, updateSelectedDate}) => {
const [isDateTimePickerVisible, setIsDateTimePickerVisible] = useState(false);
const handleDatePicked = (selectedDate) => {
setIsDateTimePickerVisible(false);
updateSelectedDate(selectedDate);
}
return <View>
<DateTimePicker
isVisible={isDateTimePickerVisible}
onConfirm={(date) => handleDatePicked(date)}
onCancel={() => setIsDateTimePickerVisible(false)}
/>
<Button onPress={() => setIsDateTimePickerVisible(true)}>
<Text>{selectedDate ? selectedDate : 'Data de nascimento (+18)'}</Text>
</Button>
</View>
}
The component parent of DateTimePickerComponent:
export default ParentComponent = () => {
const [birthdayLocal, setBirthdayLocal] = useState();
return <View>
...
<DatePickerButton
selectedDate={birthdayLocal}
updateSelectedDate={(selectedDate) => setBirthdayLocal(selectedDate)}
/>
...
</View>
}
So this is the case: on debug mode everything is working fine but on release it just doesn't show the modal to the user pick a date.
I realized that if I import the DateTimePicker directly on the parent component, it works! Just like: import DateTimePicker from "react-native-modal-datetime-picker"; But I don't wanna have to import it every time that I'm going to use it, you know, my plan it's to create a customized component and import it wherever I need it, just like in my example.
Any ideas on how to fix that?
Hi!Hm, not sure what's happening here 馃
I would suggest you to play with the example to reproduce the issue in order to better understand the source of the issue.
Alright, the problem actually is related to the props: minimumDate and maximumDate. If I set any value it stop showing the modal. If I set any value, like: minimumDate={new Date('01-01-1900')} I got an error: Malformed calls from JS: field sizes are different. This specific error only happens when I set a value on minimunDate, if I set a value in maximunDate it only doesn't open the modal, without errors.
EDIT: Fixed by changing date format from mmddyyyy to yyyymmdd. Working fine now, werdly on debug mode mmddyyyy it's acceptable.
EDIT虏: The dates must have 2 digits on month and on day, otherwise will crash the app or not show the modal.
@DiegoDevBittencourt thanks for the updates 馃憤 This is probably caused by a misaligned between the Android JS engine and the development one (they're not the same) on the Date API. Shouldn't be related to this library (you can validate it by using the community picker instead of this one.
I'm closing this issue, but feel free to open a new one if needed 馃憤
Most helpful comment
Alright, the problem actually is related to the props:
minimumDateandmaximumDate. If I set any value it stop showing the modal. If I set any value, like:minimumDate={new Date('01-01-1900')}I got an error:Malformed calls from JS: field sizes are different. This specific error only happens when I set a value on minimunDate, if I set a value in maximunDate it only doesn't open the modal, without errors.EDIT: Fixed by changing date format from
mmddyyyytoyyyymmdd. Working fine now, werdly on debug modemmddyyyyit's acceptable.EDIT虏: The dates must have 2 digits on month and on day, otherwise will crash the app or not show the modal.