Closed shahanshah87 closed 4 years ago
@stephy @peacechen @kesha-antonov @superandrew213
Hey @Shahanshah87 👋
Could please tell me what exactly doesn't work?
Have you got any errors?
It works well for me
@Shahanshah87 Refer to the example app: https://github.com/stephy/CalendarPicker/blob/master/example/App.js#L129
@Roka20012
if you use this in class component, it will work fine but when you use this in functional component.
and call the function onDateChange={() => onDateChange()}
and const onDateChange = (date, type) => { console.log(date, type); if (type === 'END_DATE') { setData({ ...data, booking_to:date, }) } else { setData({ ...data, booking_from:date, }) } }
then in log date
and type
comes undefined.
@Shahanshah87
You're not passing any parameters to your onDateChange
callback. It's unnecessary to create an anonymous function:
onDateChange={() => onDateChange()} // <-- incorrect
Refer to the example app that I linked above.
function onDateChange:-
const onDateChange = (date, type) => { console.log(date, type); if (type === 'END_DATE') { setData({ ...data, booking_to:date, }) } else { setData({ ...data, booking_from:date, }) } }
I am unable to understand what should I pass as arguement in
onDateChange={() => onDateChange(WHAT ARGUEMENT SHOULD BE PASSED HERE?)}