Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

react-native-web, DatePicker component?

I was hoping to use https://github.com/xgfe/react-native-datepicker with react-native-web but it's not compatible I think.

Is there other library that offers native datepicker look as in the image which are compatible with react-native-web?

enter image description here

like image 425
eugene Avatar asked Dec 12 '18 15:12

eugene


2 Answers

Something like this will work. You can call this component instead of the native one if you are on a web platform and it will use the default web date picker.

export default function DateTimePicker({ value, onChange }: Props) {
  
  return createElement('input', {
    type: 'date',
    value: value,
    onInput: onChange,
  })
}
like image 98
Kheva Mann Avatar answered Oct 03 '22 10:10

Kheva Mann


one possibility is to write a native input with "date" type with the createElement function from react-native-web library like i did here with select and option tags: https://gist.github.com/orYoffe/1f5d1651bab5d477730aec317ed405fc

Then you would have native behaviour on mobile web and other native supported features

like image 23
orYoffe Avatar answered Oct 03 '22 08:10

orYoffe