Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

React-native typescript & rn-select-date-range, range type incompatible

$
0
0

I use in my expo app rn-select-date-range : https://github.com/dilipchandima/rn-select-date-range

I use it as on the documentation :

const [selectedRange, setRange] = useState({      firstDate:'' ,      secondDate: '',    }); ...<DateRangePicker            onSelectDateRange={range => {              setRange(range);              hideDatePicker()            }}            blockSingleDateSelection={true}            responseFormat="YYYY-MM-DD"            maxDate={moment()}            minDate={moment().subtract(100, 'days')}            selectedDateContainerStyle={{              height: 35,              width: '100%',              alignItems: 'center',              justifyContent: 'center',              borderRadius: 17.5,              backgroundColor: '#0C8B7D',            }}            font={'BeVietnam-Regular'}            selectedDateStyle={{ fontWeight: 'bold', color: 'white' }}          />  

But ts shows me an error:

enter image description here

And if I make my useSate exactly like the doc:

const [selectedRange, setRange] = useState({  firstDate:'' ,  secondDate: '',});

I cannot access the selected values:

<Text>first date: {selectedRange.firstDate}</Text><Text>second date: {selectedRange.secondDate}</Text>

with another type error :

enter image description here

How to fix this error in your opinion?


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>