trotzig / react-available-times

A calendar to select available time slots
MIT License
98 stars 33 forks source link

Is it possible to clear the calendar? #17

Open DevKarenC opened 5 years ago

DevKarenC commented 5 years ago

I'm wondering if it's possible to clear all the times selections in the calendar. If not, I'm considering using jQuery to find and click on each of the calendar selections to delete them.

Thanks!

trotzig commented 5 years ago

Hi @DevKarenC 👋 - sorry for the late reply.

Right now it looks like the only way to clear everything would be to re-initialize the <AvailableTimes> component. Selections are stored in local state across a few components and it's tricky to get access to them all. But if you do something like

<AvailableTimes key={this.state.resetIncrement}>

and then somewhere else

<button onClick={() => this.setState({ resetIncrement: this.state.resetIncrement + 1  })}>Reset</button>

I think that could work. Note that this is untested code.