dilipchandima / rn-select-date-range

A simple and fully customizable React Native date range picker component
https://www.npmjs.com/package/rn-select-date-range
MIT License
23 stars 30 forks source link

Ability to clear the dateRange #5

Closed rocioimpa closed 3 years ago

rocioimpa commented 3 years ago

Hi, I see there is no way to clear the ranges from the calendar once they are set. Is there a way to do this? My code is:

const [range, setRange] = useState({});

const handleDateRangeChange = (value) => {
    setRange(value);
};

const handleButtonPress = useCallback(() => {
    setDateRange({});
};

return(
    <DateRangePicker
            onSelectDateRange={handleDateRangeChange}
            blockSingleDateSelection={false}
            responseFormat="DD-MM-YYYY"
            maxDate={moment().add(1, "year")}
            minDate={moment().subtract(2, "year")}
            selectedDateContainerStyle={styles.selectedDateContainerStyle}
            selectedDateStyle={styles.selectedDateStyle}
     />
     <Button onPress={handleButtonPress} mode='contained'>Clear</Button>);

Setting the state back to an empty object clears the variable, but the calendar remains with the selected dates marked.

drakyone commented 3 years ago

Same problem here

dilipchandima commented 3 years ago

We are working on a fix for this issue.

dilipchandima commented 3 years ago

@rocioimpa @drakyone I created a clear button for the component, and trying to publish the package, I published the package with public access but it is not reflecting on NPM, I opened a ticket with them I will let you know when the issue is fixed.

drakyone commented 3 years ago

@rocioimpa @drakyone I created a clear button for the component, and trying to publish the package, I published the package with public access but it is not reflecting on NPM, I opened a ticket with them I will let you know when the issue is fixed.

is it possible to make component controlled? (to set default value or something)

rocioimpa commented 3 years ago

@rocioimpa @drakyone I created a clear button for the component, and trying to publish the package, I published the package with public access but it is not reflecting on NPM, I opened a ticket with them I will let you know when the issue is fixed.

Awesome, thanks! Is there a way to control it? Like, if I set the state to the inital state (empty object), the calendar resets itself? Anyways this is great, helps a lot!

drakyone commented 3 years ago

@rocioimpa @drakyone I created a clear button for the component, and trying to publish the package, I published the package with public access but it is not reflecting on NPM, I opened a ticket with them I will let you know when the issue is fixed.

I had the same issue with npm today, just need to wait some time. thanks for this beatiful library by the way!

dilipchandima commented 3 years ago

yeah seems like they are having an issue - https://status.npmjs.org/

rocioimpa commented 3 years ago

Indeed, the library is great, very easy to use 😃

dilipchandima commented 3 years ago

The new change is available now, it is Version 3.0.1