arqex / react-datetime

A lightweight but complete datetime picker react component.
2k stars 868 forks source link

TimeConstraints option does't apply after rerender component #537

Open Cript opened 6 years ago

Cript commented 6 years ago
[x] Bug report
[ ] Feature request
[ ] Support request

Steps to Reproduce

Render Datetime component with timeConstraints property For example: { hours: { min: 9 }, minutes: { min: 30 }} Then rerender component with { hours: { min: 9 }, minutes: { min: 40 }}

Expected Results

timeConstraints should changes

Actual Results

timeConstraints does't apply after rerender component with other timeConstraints property

Other Information (e.g. stacktraces, related issues, suggestions how to fix)

I use two DateTime fields and time in second field should't be less then in a first. First DateTime component update parent state in onChangeStartTime function. this.calculateEndTimeConstraints() calculates timeConstraints. timeConstraints only work on load page (mount component). After update first DateTime field timeConstraints calculates correctly, but they don't apply in the second DateTime component.

        <Datetime onChange={this.onChangeStartTime}
          timeConstraints={this.calculateStartTimeConstraints()} timeFormat="H:mm"
                  value={this.state.formData.startTime} />

        <Datetime onChange={this.onChangeEndTime}
            timeConstraints={this.calculateEndTimeConstraints()} timeFormat="H:mm"
            value={this.state.formData.endTime} />
kumarnit commented 4 years ago

hi @Cript, have u got the solution for not affecting upadated TimeConstraints after rerendering the component.